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.
ParameterTypeRequiredDescription
modelstringYes*Target model ID (e.g. `claude-sonnet-5.5`, `claude-3-7-sonnet`, `claude-opus-5.5`).
messagesarrayYesList of messages in Anthropic format (`user` and `assistant` turns).
max_tokensintegerYesMaximum output tokens to generate (up to 8,192).
systemstring | arrayNoSystem prompt instructing the model's behavior and personality.
streambooleanNoIf true, streams partial message deltas as Anthropic SSE events.
temperaturenumberNoSampling temperature between 0.0 and 1.0.
top_pnumberNoNucleus sampling probability mass cutoff.
toolsarrayNoAnthropic tool definitions with `name`, `description`, and `input_schema`.
tool_choiceobjectNoControlling tool use (`{"type": "auto"}`, `{"type": "any"}`, etc.).

Request Headers

Header NameRequiredDescription
AuthorizationYes*Bearer token: `Bearer sk-unlocked-...` (or pass as `x-api-key`).
x-api-keyYes*Alternative Anthropic key header format: `sk-unlocked-...`.
Content-TypeYesMust be `application/json`.
anthropic-versionNoStandard 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.