Anthropic Integration

Create message (Anthropic format)

Creates a message using Anthropic Messages API format. Supports streaming via SSE.

Async inference: Send x-bf-async: true to submit the request as a background job and receive a job ID immediately. Poll with x-bf-async-id: <job-id> to retrieve the result. When the job is still processing, the response will have an empty content array. When completed, content will contain the full result. See Async Inference for details.

POST
/anthropic/v1/messages
AuthorizationBearer <token>

Bearer token authentication. Use your MPilot virtual-key JWT or admin JWT. Virtual keys (prefixed with sk-bf-) can also be passed here.

In: header

Header Parameters

x-bf-async?string

Set to true to submit this request as an async job. Returns immediately with a job ID. Not compatible with streaming.

Value in"true"
x-bf-async-id?string

Poll for results of a previously submitted async job by providing the job ID returned from the initial async request.

x-bf-async-job-result-ttl?integer

Override the default result TTL in seconds. Results expire after this duration from completion time.

Default3600
modelstring

Model identifier (e.g., claude-3-opus-20240229)

max_tokensinteger

Maximum tokens to generate

messagesarray<AnthropicMessage>

List of messages in the conversation

system?string | array<AnthropicContentBlock>

System prompt

cache_control?CacheControl

Automatic caching directives for the whole request

metadata?object
stream?boolean

Whether to stream the response

temperature?number
Range0 <= value <= 1
top_p?number
top_k?integer
stop_sequences?array<string>
tools?array<object>
tool_choice?object
mcp_servers?array<object>

MCP servers configuration (requires beta header)

thinking?object
output_format?object

Structured output format (requires beta header)

Empty Object

fallbacks?array<string>

Response Body

curl -X POST "https://loading/{AI_GATEWAY_URL}/anthropic/v1/messages" \  -H "x-bf-async: true" \  -H "x-bf-async-id: string" \  -H "x-bf-async-job-result-ttl: 3600" \  -H "Content-Type: application/json" \  -d '{    "model": "claude-3-opus-20240229",    "max_tokens": 0,    "messages": [      {        "role": "user",        "content": "string"      }    ]  }'
{
  "id": "string",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "string",
      "thinking": "string",
      "signature": "string",
      "data": "string",
      "tool_use_id": "string",
      "id": "string",
      "name": "string",
      "input": {},
      "server_name": "string",
      "content": "string",
      "source": {
        "type": "base64",
        "media_type": "string",
        "data": "string",
        "url": "string"
      },
      "cache_control": {
        "type": "ephemeral",
        "ttl": "string"
      },
      "citations": {
        "enabled": true
      },
      "context": "string",
      "title": "string"
    }
  ],
  "model": "string",
  "stop_reason": "end_turn",
  "stop_sequence": "string",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 0
    }
  }
}
{
  "type": "error",
  "error": {
    "type": "string",
    "message": "string"
  }
}
{
  "type": "error",
  "error": {
    "type": "string",
    "message": "string"
  }
}
On this page

On this page

No Headings