---
title: "Create message (Anthropic compatible)"
method: POST
path: "/v1/messages"
tags: ["Messages"]
---

# Create message (Anthropic compatible)

`POST /v1/messages`

## Request

- Base URL: `https://api.sandbase.ai`
- URL: `https://api.sandbase.ai/v1/messages`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Anthropic Messages-compatible endpoint. SandBase uses model and stream for routing, maps the public model name to the selected provider, and otherwise preserves the compatible request and response protocol. Provider compatibility rules may remove or reject unsupported beta fields before an upstream attempt.

## Headers

- `anthropic-version` string
- `anthropic-beta` string

## Request body

- object: Anthropic-compatible request. Additional fields are preserved unless a selected provider's compatibility rules remove or reject them.
  - `model` string, required
  - `max_tokens` integer, required
  - `messages` object[], required
    - `role` 'user' | 'assistant', required
    - `content` union, required
      - string
      - object[]
  - `system` union
    - string
    - object[]
  - `temperature` number
  - `top_p` number
  - `top_k` integer
  - `stop_sequences` string[]
  - `stream` boolean
  - `metadata` object
  - `tools` object[]
  - `tool_choice` object
  - `thinking` object: Extended thinking configuration when supported by the selected model.

## Response `200`

Anthropic message response or event stream from the selected provider

- AnthropicMessageResponse: Anthropic-compatible response forwarded from the selected provider. Fields can vary with beta features.
  - `id` string
  - `type` 'message'
  - `role` 'assistant'
  - `model` string
  - `content` object[]
  - `stop_reason` string, nullable
  - `stop_sequence` string, nullable
  - `usage` object
    - `input_tokens` integer
    - `output_tokens` integer
    - `cache_read_input_tokens` integer
    - `cache_creation_input_tokens` integer
    - `cache_creation` object
      - `ephemeral_5m_input_tokens` integer
      - `ephemeral_1h_input_tokens` integer

## Other responses

- `400`: Invalid JSON, missing model, unsupported feature, or invalid provider request
- `401`: Missing, invalid, revoked, or expired API key
- `402`: Organization balance and credit are exhausted
- `403`: API Key spending limit reached, organization disabled, or upstream permission rejected
- `404`: Model or upstream resource not found
- `413`: Provider rejected the request as too large
- `429`: Provider rate limit exceeded
- `500`: Prediction lifecycle or provider error
- `502`: Upstream stream ended before usable content
- `503`: Routing failed or all provider candidates were unavailable

---

[API](https://skmtc.dev/sandbase/apis/sandbase-api.md) · [All operations](https://skmtc.dev/sandbase/apis/sandbase-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbase/apis/sandbase-api/revisions/d40df2467ba2?raw)
