api/EndpointsPOST
POST /v1/messages
Native Anthropic Messages API specification for Claude Code, Anthropic SDKs, and agents.
Endpoint Specification
`POST https://unlockedai.net/v1/messages`
Creates a message response conforming directly to the Anthropic Messages API wire protocol. Powers **Claude Code CLI**, `@anthropic-ai/sdk`, and `@anthropic-ai/claude-agent-sdk` directly with your Unlocked AI API key and credits.
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes* | Target model ID (e.g. `claude-sonnet-5.5`, `claude-3-7-sonnet`, `claude-opus-5.5`). |
| messages | array | Yes | List of messages in Anthropic format (`user` and `assistant` turns). |
| max_tokens | integer | Yes | Maximum output tokens to generate (up to 8,192). |
| system | string | array | No | System prompt instructing the model's behavior and personality. |
| stream | boolean | No | If true, streams partial message deltas as Anthropic SSE events. |
| temperature | number | No | Sampling temperature between 0.0 and 1.0. |
| top_p | number | No | Nucleus sampling probability mass cutoff. |
| tools | array | No | Anthropic tool definitions with `name`, `description`, and `input_schema`. |
| tool_choice | object | No | Controlling tool use (`{"type": "auto"}`, `{"type": "any"}`, etc.). |
Request Headers
| Header Name | Required | Description |
|---|---|---|
| Authorization | Yes* | Bearer token: `Bearer sk-unlocked-...` (or pass as `x-api-key`). |
| x-api-key | Yes* | Alternative Anthropic key header format: `sk-unlocked-...`. |
| Content-Type | Yes | Must be `application/json`. |
| anthropic-version | No | Standard Anthropic API version string (e.g. `2023-06-01`). |
Response Payload Schema
{
"id": "msg_011CgZc24bcyJwcmwr4JbWDE",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I am ready to help you analyze code and build applications."
}
],
"model": "claude-sonnet-5.5",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 17,
"output_tokens": 16
}
}Need an Unlocked AI Key or Credits?
Generate secret API keys backed by non-expiring pay-as-you-go credits starting at $5. No monthly minimums.