curl https://api.pipellm.ai/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $PIPELLM_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'
import os
import anthropic
client = anthropic.Anthropic(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai",
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
{
"id": "<string>",
"type": "<string>",
"role": "<string>",
"content": [
{}
],
"stop_reason": "<string>",
"usage": {}
}Create a message
Create a message with the Anthropic Messages API.
POST
/
v1
/
messages
curl https://api.pipellm.ai/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $PIPELLM_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'
import os
import anthropic
client = anthropic.Anthropic(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai",
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
{
"id": "<string>",
"type": "<string>",
"role": "<string>",
"content": [
{}
],
"stop_reason": "<string>",
"usage": {}
}Use
x-api-key: $PIPELLM_API_KEY and anthropic-version: 2023-06-01. Native /v1/messages only routes to Anthropic-compatible platforms.
curl https://api.pipellm.ai/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $PIPELLM_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'
import os
import anthropic
client = anthropic.Anthropic(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai",
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
string
required
Anthropic model ID from
GET /v1/models.array
required
Conversation messages. Roles are
user or assistant.Show messages[]
Show messages[]
string
required
user or assistant.integer
required
Maximum output tokens.
string | array
System prompt.
number
Sampling temperature, 0–1.
number
Nucleus sampling.
integer
Top-k sampling.
boolean
If
true, return server-sent events.string[]
Custom stop sequences.
array
Endpoint
POST https://api.pipellm.ai/v1/messages
This free route accepts Anthropic Messages requests and routes only to
Anthropic-compatible platforms. To keep the Anthropic format while calling
OpenAI or Gemini models, use the
Anthropic Format Converter.
Install SDKs
- Python
- Node.js
- Go
pip install anthropic
npm install @anthropic-ai/sdk
go get github.com/anthropics/anthropic-sdk-go
Code Examples
- cURL
- Python
- Node.js
- Go
curl https://api.pipellm.ai/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $PIPELLM_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d @- << 'EOF'
{
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Why is the sky blue?"}
]
}
EOF
import os
import anthropic
client = anthropic.Anthropic(
api_key=os.getenv('PIPELLM_API_KEY'),
base_url='https://api.pipellm.ai'
)
message = client.messages.create(
model='claude-sonnet-4-5-20250929',
max_tokens=1024,
messages=[
{'role': 'user', 'content': 'Why is the sky blue?'}
]
)
print(message.content[0].text)
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: process.env.PIPELLM_API_KEY,
baseURL: 'https://api.pipellm.ai'
});
const message = await client.messages.create({
model: 'claude-sonnet-4-5-20250929',
max_tokens: 1024,
messages: [
{ role: 'user', content: 'Why is the sky blue?' }
]
});
console.log(message.content[0].text);
package main
import (
"context"
"os"
"github.com/anthropics/anthropic-sdk-go"
"github.com/anthropics/anthropic-sdk-go/option"
)
func main() {
client := anthropic.NewClient(
option.WithAPIKey(os.Getenv("PIPELLM_API_KEY")),
option.WithBaseURL("https://api.pipellm.ai"),
)
message, _ := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
Model: anthropic.F("claude-sonnet-4-5-20250929"),
MaxTokens: anthropic.Int(1024),
Messages: anthropic.F([]anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("Why is the sky blue?")),
}),
})
}
Response Format
{
"id": "msg_xxx",
"type": "message",
"role": "assistant",
"content": [
{"type": "text", "text": "The sky appears blue because..."}
],
"model": "claude-sonnet-4-5-20250929",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 10,
"output_tokens": 50
}
}
string
Message ID.
string
Always
message.string
Always
assistant.array
Output blocks. Text replies use
{ "type": "text", "text": "..." }. Tool calls use tool_use blocks.string
end_turn, max_tokens, or tool_use.object
input_tokens and output_tokens.Errors
Same envelope as Errors. Native/v1/messages also returns 400 when the body is not Anthropic format.
400 invalid_request_error
400 invalid_request_error
Missing
model, messages, or max_tokens, or a protocol mismatch.{
"error": {
"type": "invalid_request_error",
"code": "400",
"message": "The 'model' field is required but was not provided in the request"
}
}
401 authentication_error
401 authentication_error
Missing or invalid
x-api-key.{
"error": {
"type": "authentication_error",
"code": "401",
"message": "Incorrect API key provided. Please visit https://console.pipellm.ai/account/api-keys to find your API key."
}
}
402 insufficient_balance
402 insufficient_balance
{
"error": {
"type": "insufficient_balance",
"code": "402",
"message": "Insufficient balance. Please recharge your account at https://console.pipellm.ai/billing."
}
}
429 rate_limit_error
429 rate_limit_error
See Rate Limits.
{
"error": {
"type": "rate_limit_error",
"code": "429",
"message": "Rate limit exceeded. Your current limit is 120 requests per minute (approximately 2.00 requests per second). Please visit https://console.pipellm.ai/billing to upgrade your plan for higher limits."
}
}
Related Docs
Routing & Protocols
Native-route constraints and converter routes
Anthropic Overview
Headers, models, and route family overview
Anthropic Format Converter
Keep Anthropic format while calling other providers
Was this page helpful?