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

# Create message (Anthropic-compatible)

`POST /v1/messages`

## Request

- Base URL: `https://api.tokenlab.sh`
- URL: `https://api.tokenlab.sh/v1/messages`
- Auth: HTTP bearer

Creates a model response using Anthropic's native request format. Supports Claude models with vision and streaming.

**Authentication:** Use `x-api-key` header or `Authorization: Bearer` header.

## Headers

- `X-TokenLab-Delivery-Policy` 'auto' | 'verified' | 'official'

## Request body

- AnthropicMessagesRequest
  - `model` string, required: Model to use (e.g., claude-sonnet-4-6)
  - `max_tokens` integer, required: Maximum number of tokens to generate
  - `messages` object[], required: Messages in the conversation
    - `role` 'user' | 'assistant', required
    - `content` union, required
      - string
      - object[]
        - `type` 'text' | 'image'
        - `text` string
        - `source` object
          - `type` 'base64' | 'url'
          - `media_type` string
          - `data` string
          - `url` string
  - `system` string: System prompt
  - `temperature` number
  - `top_p` number
  - `top_k` integer
  - `stop_sequences` string[]
  - `stream` boolean
  - `tools` object[]: Tool definitions available to the model.
  - `tool_choice` union: Tool choice policy or explicit tool selection.
    - string
    - object
  - `metadata` object: Request metadata echoed into downstream logs or traces when supported.
  - `thinking` object: Thinking configuration for compatible Anthropic-style models.
  - `stream_options` object: Streaming options such as usage chunk inclusion.
  - `service_tier` string: Service tier hint where supported by the model.

## Response `200`

Successful response

- AnthropicMessagesResponse
  - `id` string
  - `type` 'message'
  - `role` 'assistant'
  - `model` string
  - `content` object[]
    - `type` 'text'
    - `text` string
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use'
  - `stop_sequence` string, nullable
  - `usage` object
    - `input_tokens` integer
    - `output_tokens` integer

## Other responses

- `400`: Bad Request - Invalid input
- `401`: Unauthorized - Invalid or missing API key
- `402`: Payment Required - Insufficient balance or quota exceeded
- `429`: Rate Limit Exceeded
- `500`: Internal Server Error
- `503`: The requested Delivery tier is temporarily unavailable.

---

[API](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway.md) · [All operations](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/revisions/3208bfbcda22?raw)
