Zum Inhalt springen
DeutschlandGPT

Create a message

Native Anthropic Messages endpoint — a faithful subset of Anthropic’s public Messages contract, so the Anthropic SDKs and Claude Code work unmodified. Point them at https://api.deutschlandgpt.de/anthropic (self-hosted: https://<your-domain>/platform-api/api/anthropic) and every model hosted on the platform (Claude, GPT, Gemini, Mistral, …) is reachable through this wire format, not just Claude. That base URL is a sibling of the OpenAI-compatible /v2 surface, not a path inside it: the SDK appends /v1/messages itself, so a base URL containing /v2 returns 404.

Authenticate with x-api-key: sk_<id>_<secret> (the Anthropic SDK default) or Authorization: Bearer sk_<id>_<secret>. Responses carry anthropic-version: 2023-06-01.

Supports streaming via SSE (stream: true), tool use, extended thinking (thinking), images and documents, and prompt caching via cache_control breakpoints (honoured on Anthropic-family hosts, a no-op elsewhere). Breakpoints are yours to place: this endpoint caches exactly what you mark and never adds breakpoints of its own, so a request without cache_control is not cached at all. ttl: "1h" is supported on this endpoint — it is Anthropic's own field here, not an extension of ours — and you may mix it with the default 5m in one request (Anthropic's own 1h-prefix/5m-tail pattern), with each bucket billed at its own rate. Anthropic's ordering rule applies: 1h breakpoints must come before any 5m one. Note this is the ONLY endpoint where ttl: "1h" is honoured; /v2/chat/completions and /v2/responses accept it and fall back to five minutes. The per-TTL write split is returned in Anthropic's own usage.cache_creation field, and prompt_cache.warnings reports any marker we could not place exactly as written. See Billing → Prompt caching.

Not supported: server tools (web_search_*, …), the Batches API, and service_tier (accepted but ignored).

POSThttps://api.deutschlandgpt.de/anthropic/v1/messages

Example request

curl https://api.deutschlandgpt.de/anthropic/v1/messages \
  -X POST \
  -H "Authorization: Bearer $DGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "claude-4.5-sonnet",
  "max_tokens": 0,
  "messages": [
    {
      "role": "user",
      "content": "string"
    }
  ],
  "system": "string",
  "tools": [
    {
      "name": "string"
    }
  ],
  "tool_choice": {
    "type": "auto"
  },
  "temperature": 0,
  "top_p": 0,
  "top_k": 0,
  "stop_sequences": [
    "string"
  ],
  "stream": false,
  "thinking": {
    "type": "enabled",
    "budget_tokens": 0
  },
  "metadata": {},
  "service_tier": "string"
}'

Request body

modelstringrequired

Registry model name (e.g. claude-4.5-sonnet, gpt-4o, mistral-large). Every hosted model is reachable through this endpoint — not just Claude. Use /anthropic/v1/models to enumerate.

max_tokensintegerrequired

Maximum number of tokens to generate. Required (unlike the OpenAI-compatible endpoints).

messagesAnthropicMessage[]required

Alternating user / assistant turns. System instructions go in the top-level system field, not here.

rolestringrequired
contentstring | AnthropicContentBlock[]required

A bare string (shorthand for one text block) or a list of content blocks.

systemstring | AnthropicTextBlock[]optional

System prompt: a bare string or a list of text blocks (each block can carry a cache_control breakpoint).

toolsAnthropicTool[]optional

Custom tools the model may call. Return each tool_use result in a following user message as a tool_result block.

typestringoptional

Omit, or custom. Other values mark unsupported server tools.

namestringrequired
descriptionstringoptional

What the tool does — the model uses this to decide when to call it.

input_schemaobjectoptional

JSON Schema of the tool’s arguments.

cache_controlAnthropicCacheControloptional

Prompt-caching breakpoint. Honoured when the request is served by an Anthropic-family host; a no-op for other providers.

typestringrequired
ttlstringoptional

Cache time-to-live.

tool_choiceAnthropicToolChoiceoptional

How the model should use the provided tools.

temperaturenumberoptional

Sampling temperature. Higher = more random output.

top_pnumberoptional

Nucleus sampling.

top_knumberoptional

Only sample from the top K options per token.

stop_sequencesstring[]optional

Custom sequences that stop generation.

streambooleanoptional

If true, respond with server-sent events in Anthropic’s streaming format: message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop.

thinkingAnthropicThinkingConfigoptional

Extended-thinking configuration. Mapped to the equivalent reasoning options of whichever provider hosts the selected model.

metadataobjectoptional

Request metadata.

user_idstring | nulloptional

Opaque end-user identifier.

service_tierstringoptional

Accepted but ignored — routing is decided server-side.

Response

200application/json
{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "model": "string",
  "content": [
    {
      "type": "text",
      "text": "string"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": "string",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  },
  "prompt_cache": {
    "cache_write_tokens": {
      "5m": 0,
      "1h": 0
    },
    "warnings": [
      {
        "code": "breakpoint_limit_exceeded",
        "message": "string"
      }
    ]
  }
}

The generated message. With stream: true, a text/event-stream of Anthropic streaming events is returned instead.

idstringrequired
typestringrequired
rolestringrequired
modelstringrequired
contentAnthropicResponseContentBlock[]required
stop_reasonstringrequired
stop_sequencestring | nulloptional
usageAnthropicUsagerequired
input_tokensintegerrequired
output_tokensintegerrequired
cache_creation_input_tokensintegerrequired

Tokens written to the prompt cache (0 for providers without prompt caching).

cache_read_input_tokensintegerrequired

Tokens served from the prompt cache (0 for providers without prompt caching).

prompt_cacheobjectoptional

DeutschlandGPT extension. What happened to the cache_control breakpoints you sent. Omitted entirely when there is nothing to report, so a request without cache_control is unchanged. See Billing -> Prompt caching.

cache_write_tokensobject

Cache-write tokens by TTL, as the upstream host reported them: 125% of the input rate for 5m, 200% for 1h. Both TTLs are honoured on this endpoint.

5minteger

Tokens written at the default 5-minute TTL.

1hinteger

Tokens written at the extended 1-hour TTL.

warningsobject[]

Breakpoints that could not be honoured exactly as written. Present only when at least one was affected.

codestringrequired

Stable machine-readable reason, so a client can branch without parsing prose.

messagestringrequired

Human-readable explanation naming the affected position.

Response codes

200

The generated message. With stream: true, a text/event-stream of Anthropic streaming events is returned instead.

AnthropicMessageResponse
400

Invalid request body.

AnthropicError
401

Missing or invalid API key.

AnthropicError
404

Model not found, or the API key has no access to it.

AnthropicError
Was this page helpful?