Skip to main content
POST
/
v1
/
messages
curl --request POST \
  --url https://api.getinfinityblue.com/v1/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'anthropic-version: <anthropic-version>' \
  --data '
{
  "model": "claude-3-opus-20240229",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Introduce yourself in one sentence."
    }
  ]
}
'
{
  "id": "<string>",
  "type": "<string>",
  "role": "<string>",
  "content": [
    {
      "type": "<string>",
      "text": "<string>"
    }
  ],
  "model": "<string>",
  "usage": {
    "input_tokens": 123,
    "output_tokens": 123,
    "cache_creation_input_tokens": 123,
    "cache_read_input_tokens": 123
  }
}

Models you can use

Model IDNotes
claude-3-opus-20240229Claude 3 flagship — top reasoning and comprehension
claude-3-5-sonnet-20241022Claude 3.5 Sonnet — balanced performance
claude-3-5-haiku-20241022Claude 3.5 Haiku — fast and lightweight
See GET /v1/models for the full list.

Version header

Every request must include anthropic-version: 2023-06-01 (or a newer version).

System prompt

The system field can be a plain text string or an array of content blocks with cache-control directives for fine-grained prompt caching.

Tool calling

Define tools in tools using a JSON Schema input_schema. The model returns tool_use blocks in content; feed back the tool result as a tool_result block in the next turn.

Extended thinking

Set thinking.type: enabled and specify thinking.budget_tokens to enable extended thinking mode. The model returns thinking content blocks alongside the final answer.

Streaming

Set stream: true for SSE streaming. Event types include message_start, content_block_delta, and message_stop.

Authorizations

Authorization
string
header
required

Bearer token authentication, format: Authorization: Bearer sk-xxxxxx. Get your API key in the console.

Headers

anthropic-version
string
required

Anthropic API version. Recommended value is 2023-06-01.

Example:

"2023-06-01"

x-api-key
string

Anthropic API key (optional). You can use this header or the standard Authorization: Bearer YOUR_KEY header — either works.

Body

application/json

Anthropic Claude Messages API request body.

model
string
required

Model ID, e.g. claude-3-opus-20240229. See GET /v1/models for the full list.

Example:

"claude-3-opus-20240229"

messages
object[]
required

Conversation messages. role must alternate between user and assistant.

max_tokens
integer
required

Maximum number of tokens the model may generate. Required.

Required range: x >= 1
system

System prompt — either a plain text string or an array of content blocks with cache-control directives.

temperature
number

Sampling temperature between 0 and 1, controlling output randomness.

Required range: 0 <= x <= 1
top_p
number

Nucleus sampling threshold. Tune this or temperature, not both.

top_k
integer

Top-K sampling — only the K most probable tokens are considered.

stream
boolean

Whether to stream the response as Server-Sent Events.

stop_sequences
string[]

Stop sequences — generation halts when any of these is produced.

tools
object[]

Tools the model may call. Each tool requires name, description, and input_schema.

tool_choice
object

Tool calling strategy. auto lets the model decide, any forces at least one tool call, tool forces a specific tool (also set name).

thinking
object

Extended thinking configuration, only effective for models that support it.

metadata
object

Additional request metadata.

Response

Successful response

Anthropic Claude Messages API response body.

id
string

Unique identifier for this message.

type
string

Object type, value is message.

Example:

"message"

role
string

Response role, value is assistant.

Example:

"assistant"

content
object[]

List of response content blocks — may include text, tool_use, or thinking blocks.

model
string

The model that actually processed the request.

stop_reason
enum<string>

The reason generation stopped.

Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use
usage
object

Token usage statistics.