Docs contents

Anthropic-compatible API (Messages)

Call models through POST /v1/messages and count tokens with /v1/messages/count_tokens on GoiAPI; works with Claude Code and the Anthropic SDKs.

Ask AI and more
View as Markdown

An endpoint compatible with the Anthropic Messages API. Claude Code and the Anthropic SDKs only need the base URL set to https://api.goiapi.com (the SDK appends /v1/messages itself).

HTTP
POST https://api.goiapi.com/v1/messages

Headers

  • x-api-key: <API_KEY> (or Authorization: Bearer <API_KEY>).
  • anthropic-version: optional, defaults to 2023-06-01.
  • anthropic-beta: optional; send it to use beta features the model supports.

Body

JSON in the Anthropic Messages format. model, max_tokens and messages are required.

Terminal
curl https://api.goiapi.com/v1/messages \
  -H "x-api-key: <API_KEY>" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-5-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Briefly explain prompt caching"}]
  }'

Returns a Messages JSON response. For streaming ("stream": true), see Streaming.

Count tokens (free)

HTTP
POST https://api.goiapi.com/v1/messages/count_tokens

The body is the same as for /v1/messages (max_tokens is not needed). Returns {"input_tokens": N}. This request is free of charge. For some models the number is an estimate (slightly on the high side).