Anthropic Messages

For file inputs, upload through the Files API, then reference the returned file_id. The gateway converts the input; provider acceptance is determined upstream.

Use {"type":"document","source":{"type":"file","file_id":"..."}} inside messages[].content. Use type: image for images; audio and video are extension types and must match the actual file. /v1/messages/count_tokens also supports these references.

Use POST /v1/messages for Anthropic-compatible Messages requests. This endpoint is useful for Claude-style clients that expect content blocks, max_tokens, system, and stop_reason instead of OpenAI chat choices.

Endpoint

https://api.inoneapi.com/v1/messages

# -H "X-APP-NAME: Your App Name"
# -H "X-APP-URL: https://your-app.example.com"
curl "https://api.inoneapi.com/v1/messages" \
  -H "x-api-key: $INONEAPI_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "YOUR_MODEL_ID",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}'

Parameters

FieldTypeRequiredDetails
modelstringyesPublic InOneAPI model ID with Anthropic protocol support.
max_tokensnumberyesMaximum tokens to generate. Anthropic-style requests require this field.
messagesarrayyesOrdered conversation turns. Roles are usually user and assistant.
systemstring/arraynoSystem instruction outside the messages array.
temperaturenumbernoSampling randomness. Provider and model limits apply.
top_pnumbernoNucleus sampling control.
top_knumbernoAnthropic-style candidate sampling limit when supported.
stop_sequencesarraynoCustom stop strings.
streambooleannoReturns Anthropic event stream format when supported.
toolsarraynoAnthropic-compatible tool definitions.
tool_choiceobjectnoControls automatic, required, or named tool use.
metadataobjectnoApplication metadata. Do not include secrets.

Content blocks

Message content may be a plain string or an array of typed blocks. Text is the most common block. Models with vision support may accept image blocks depending on the configured mapping.

{
  "role": "user",
  "content": [
    { "type": "text", "text": "Extract the key risks." }
  ]
}

Tool results should be sent back as user messages with tool_result blocks when your client uses Anthropic tool use. Keep tool IDs exactly as returned by the model.

Response

The response contains assistant content blocks and Anthropic-style token usage.

{
  "id": "msg_...",
  "type": "message",
  "role": "assistant",
  "model": "YOUR_MODEL_ID",
  "content": [
    { "type": "text", "text": "Start with a stable trace ID at ingress..." }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 42,
    "output_tokens": 28
  }
}

Token counting

Use POST /v1/messages/count_tokens when a compatible mapping exposes token counting. The request body mirrors Messages fields and returns input_tokens.

curl https://api.inoneapi.com/v1/messages/count_tokens \
  -H "Authorization: Bearer $INONEAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [
      { "role": "user", "content": "Count this." }
    ]
  }'

Streaming and errors

Streaming returns provider-style events. Handle content deltas, tool-use deltas, message stop events, and terminal errors separately. Keep X-Gateway-Trace-ID for diagnostics.

Common failures are missing max_tokens, unsupported content blocks, model restrictions, budget limits, and upstream mapping errors. Use 401/403 for credentials and access, 429 for budget or rate pressure, and 5xx with the trace ID for gateway or upstream failures.

Anthropic Messages · Documentation · InOneAPI