Skip to content

Create Anthropic Message

client.messages.create(params)
POST/v1/messages

Create a message through SandBase's Anthropic-compatible Messages endpoint. SandBase maps the model for the selected provider and preserves compatible request and response fields.

Request headers

Optional<string>x-api-key

SandBase API key. Authorization: Bearer is also accepted; x-api-key takes precedence when both are present.

Optional<string>anthropic-version

Anthropic API version forwarded upstream. SandBase supplies 2023-06-01 when omitted.

Default: 2023-06-01

Optional<string>anthropic-beta

Comma-separated beta feature identifiers, subject to provider compatibility.

Request body

MessageCreateParams
stringmodelrequired

Anthropic-compatible model identifier.

object[]messagesrequired

User and assistant messages containing text or typed content blocks.

integermax_tokensrequired

Maximum number of output tokens.

Optional<string | object[]>system

Top-level system instruction.

Optional<number>temperature

Sampling temperature from 0 to 1.

Default: 1

Optional<number>top_p

Nucleus sampling threshold.

Optional<integer>top_k

Limit sampling to the top K tokens.

Optional<string[]>stop_sequences

Custom sequences that stop generation.

Optional<boolean>stream

Return Anthropic-style Server-Sent Events.

Default: false

Optional<object>metadata

Request metadata, including an optional user_id.

Optional<object[]>tools

Tool definitions available to the model.

Optional<object>tool_choice

Controls tool selection behavior.

Optional<object>thinking

Extended thinking configuration for supported models.

Authentication

Use x-api-key or Authorization: Bearer. When both are provided, x-api-key takes precedence.

Transparent protocol

Except for model mapping and configured provider compatibility rules, SandBase forwards compatible request fields, non-stream responses, and SSE events without protocol translation.

Beta features

anthropic-beta is forwarded when present. A candidate's compatibility rules may remove unsupported beta fields or skip that candidate.

Errors

400

Invalid request body or unsupported feature.

401

Missing or invalid API key.

402

Organization spending limit reached.

403

API Key spending limit or organization permission failure.

404

Model not found or unavailable.

413

The 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.