Messages

Anthropic-compatible messages endpoint. Content blocks, extended thinking, tool use, and streaming from a single surface.

The Messages API accepts requests in the Anthropic Messages format. Any official Anthropic SDK works out of the box - just point its base URL at https://api.aivene.com (the SDK adds /v1/messages itself).

POST /v1/messages

Send the conversation so far as a list of messages made of content blocks, plus an optional system prompt, and the model replies with the next assistant turn. Stream the response with stream: true to receive named server-sent events, or get a single JSON payload otherwise.

What you can do

  • Generate text - from one-shot answers to multi-turn agentic loops.
  • Use tools - register tools with a JSON input_schema and let the model decide when to call them. See Tool use.
  • Think before answering - turn on extended thinking with thinking and control effort with output_config.effort. See Reasoning.
  • Read images and documents - attach image and document blocks to a user message. See Multimodal.
  • Cache long prompts - mark stable prefixes with cache_control. See Prompt caching.

Choosing a model

Every text model in the catalogue is available on this endpoint, not only Claude models. The model id you send determines which model serves the request, and the response echoes that same id. Some features depend on the model, for example thinking, document blocks, or the Anthropic-defined client tools. Browse available models at Models or GET /v1/models.

Authentication

This endpoint accepts the API key in either header:

  • Authorization: Bearer <api_key>
  • x-api-key: <api_key> - the header the Anthropic SDKs send.

When both are present, Authorization wins. Create keys at Manage API Keys. See Authentication.

Endpoints

MethodEndpointDescription
POST/v1/messagesCreate message

Errors

Errors returned before the response starts share one shape:

{ "error": { "message": "...", "type": "invalid_request_error" } }
Statuserror.typeMeaning
400validation_errorThe body failed schema validation. The message names the offending field.
400invalid_request_errorUnknown model, content or a feature the model does not support (for example images, tools or output_config.format), or max_tokens above the model's limit.
401authentication_errorMissing or invalid API key.
402invalid_request_errorNot enough credit for the request, an unpaid balance, or a spend limit was reached.
403permission_denied_errorThe account is suspended, an Admin key was used, or the model isn't included in your organization's tier.
404not_found_errorThe model is deprecated. The message names its replacement.
408timeout_errorThe model did not finish before the request timed out (non-streaming requests).
429rate_limit_errorYour organization hit its rate limit for this model. Back off and retry.
500internal_server_errorUnexpected server error.
502 / 503upstream_errorThe model is temporarily unavailable. Safe to retry.

Errors that happen after a stream has started arrive as an error event instead. See Streaming events.