Messages
POST https://api.inferam.ai/v1/messages is Anthropic’s Messages format, which Claude Code and DeepSeek Harness use. Inferam translates it to the model server’s Chat Completions format and back, including streaming events.
curl https://api.inferam.ai/v1/messages \ -H "x-api-key: $INFERAM_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "DeepSeek-V4.1-Flash-1017", "max_tokens": 1024, "system": "You are a terse senior engineer.", "messages": [{"role": "user", "content": "What does a WAL protect against?"}] }'Authorization: Bearer works here too. The anthropic-version and anthropic-beta headers are accepted and ignored.
Supported fields
Section titled “Supported fields”model, messages, system (a string or text blocks), max_tokens, stream, stop_sequences, temperature, top_p, tools, tool_choice (auto, any, tool, none, and disable_parallel_tool_use), thinking and output_config.effort.
- Content blocks:
text,image(base64 source only),tool_use,tool_resultandthinking. Other block types get a400. - Tools: client tools with an
input_schema. Anthropic server tools such as web search don’t run on Inferam.
Thinking
Section titled “Thinking”The model thinks by default, and its reasoning comes back as thinking blocks before the answer. Their signature is always an empty string: Inferam has no signatures to give. Send thinking blocks back unchanged in assistant turns that made tool calls; the model expects its own reasoning on those turns.
| Request | Effect |
|---|---|
"thinking": {"type": "disabled"} |
Thinking off |
"thinking": {"type": "enabled", "budget_tokens": 4000} |
Reasoning capped at 4,000 tokens |
"output_config": {"effort": "high"} |
Reasoning effort: low, medium, high, xhigh or max |
Streaming
Section titled “Streaming”With "stream": true you get the standard events: message_start, then content_block_start, content_block_delta (thinking_delta, text_delta, input_json_delta) and content_block_stop, then message_delta with the stop reason and usage, then message_stop. A failure after streaming has started is sent as an error event.
Stop reasons: end_turn, max_tokens and tool_use. A matched stop sequence ends the turn as end_turn, and stop_sequence is always null.
"usage": { "input_tokens": 256, "cache_read_input_tokens": 1792, "cache_creation_input_tokens": 0, "output_tokens": 312}As in Anthropic’s API, input_tokens excludes the tokens read from cache. The total input is input_tokens + cache_read_input_tokens.
Counting tokens
Section titled “Counting tokens”POST /v1/messages/count_tokens takes the same body and returns {"input_tokens": N}. It’s a fast estimate (about four characters per token) that doesn’t call the model and isn’t metered. Use it for budgeting, not exact accounting.