Skip to main content
POST
Messages

Request

Pass your API key in the x-api-key header or as a Bearer token.

Body

Response

Streaming

Set "stream": true to receive Server-Sent Events:

Anthropic SDK

This endpoint is fully compatible with the Anthropic SDK. Just change the base_url and api_key:

Using with Claude Code

You can use ModelsLab’s LLM API as a backend for Claude Code, Anthropic’s CLI coding assistant:
This lets you use any of ModelsLab’s 200+ LLM models as the backend for Claude Code’s agentic coding capabilities.

Authorizations

x-api-key
string
header
required

API key authentication via x-api-key header

Headers

anthropic-version
string
default:2023-06-01

Anthropic API version

Body

application/json
model
string
required

Model ID to use

max_tokens
integer
required

Maximum number of tokens to generate

Required range: x >= 1
messages
object[]
required

Array of input messages

system
string

System prompt

temperature
number
default:1

Sampling temperature

Required range: 0 <= x <= 1
top_p
number

Nucleus sampling parameter

Required range: 0 <= x <= 1
stream
boolean
default:false

Whether to stream the response

Response

Message response

id
string

Unique message ID

type
enum<string>
Available options:
message
role
enum<string>
Available options:
assistant
content
object[]
model
string
stop_reason
enum<string>
Available options:
end_turn,
max_tokens,
stop_sequence
usage
object