Zum Inhalt springen
DeutschlandGPT

Create response

Creates a model response using the stateless Responses API. An alternative to /v2/chat/completions with a simpler input format and richer streaming events.

Accepts a plain string or an array of input items (messages, function calls, function call outputs and reasoning items). The store field must be omitted or set to false — only stateless mode is supported. previous_response_id is not supported either: a request that sets it gets a 400 with error code previous_response_not_found, so send the full conversation in input.

Prompt caching (Anthropic models). Cache lifetime is five minutes only — ttl: "1h" is NOT supported on this endpoint. Mark the last element of a stable prefix with cache_control and that prefix is cached upstream, so a later request that repeats it byte-for-byte is billed at the cache-read rate. Nothing is cached unless you ask: we never insert breakpoints on your behalf, because whether a cache write pays for itself depends on your access pattern, not on ours. Every cache lives five minutes — ttl: "1h" is accepted but not supported yet, and is reported as marker_ttl_unsupported rather than applied. prompt_cache in the response carries that warning plus any marker we could not place exactly as written. See Billing → Prompt caching.

Prompt caching (Mistral models). Mistral caches prefixes automatically, so cache_control does nothing there — send prompt_cache_key instead: one stable string per conversation or session, repeated on every request that shares a prefix. It is applied unconditionally and costs nothing extra (Mistral has no cache-write premium), your value is namespaced to your workspace, and a hit is a likelihood rather than a guarantee. See Billing → Mistral models.

Tool calls re-send the whole prompt

A request with tools takes several model steps. With your own function tools, every round trip (your tool result sent back) is a new request that carries the whole conversation again. Every step pays for the whole prompt again, so without caching one request with tools can cost several times a single answer.

Mark the stable part of your prompt with cache_control (see Billing → Prompt caching): each later step then reads it at the cache-read rate. Measured on our side for a two-step request with a 7,600-token prompt and a cache point at the end of each step: about 20 % cheaper with a cold cache, and up to about 80 % cheaper when the same prompt comes again within five minutes.

Time limits. A request without stream: true is limited to 5 minutes in total and is aborted if the generation takes longer. For long generations, use stream: true: a stream has no total time limit (its length is bounded by max_output_tokens) and is ended only after 5 minutes without model output, with an error event (code: "timeout") instead of response.completed. While the model is working without output you can see, the stream carries a keepalive every 15 seconds: an SSE comment line (: keepalive), which SSE clients ignore.

Output limit. A response the model could not finish within max_output_tokens ends with status: "incomplete" and incomplete_details.reason: "max_output_tokens" (streamed: a response.incomplete event instead of response.completed). Its usage counts every token, reasoning included; raise the limit or lower the reasoning effort and send it again. Without max_output_tokens, most models may write up to their maximum output length. This holds for structured output (text.format of type json_schema or json_object) too: the message then carries the JSON text the model wrote up to the limit, unparsed and usually incomplete.

Tools. Declare function tools in the flat Responses format: {"type": "function", "name": "get_weather", "parameters": {…}}. The Chat Completions format, with the function nested under function ({"type": "function", "function": {"name": "get_weather", "parameters": {…}}}), is accepted too, so a client can send the same tool list to both endpoints. parameters is optional: without it, or with null, the function takes no arguments. A null description or strict counts as absent. A function tool that is still unusable, for example one without a name or whose parameters is not an object, is answered with HTTP 400 and error.type: "invalid_request_error"; error.param names the field as you sent it, such as tools[1].name or tools[0].function.name. Built-in tool types such as web_search or local_shell are accepted for client compatibility and not offered to the model.

Structured output. text.format of type json_schema also works with stream: true: the JSON arrives as response.output_text.delta events, and the model receives your schema exactly as in a request without streaming. If the model finishes on its own and its answer is not valid JSON or does not match your schema, a request without streaming fails with HTTP 422 and error.code: "structured_output_invalid". A streamed request has already sent its text by then, so it ends with an error event carrying the same code instead of response.completed. In both cases the tokens it used are billed, as for any finished generation.

Reasoning effort. reasoning.effort (or reasoning_effort) applies to every reasoning model on this endpoint, Claude and Mistral included, the same way as on chat completions. none switches thinking off where the model allows it. On a model that thinks by default, send it explicitly: a request without an effort keeps the model's own default. The thinking such a model hands back arrives as a reasoning output item.

POSThttps://api.deutschlandgpt.de/v2/responses

Example request

curl https://api.deutschlandgpt.de/v2/responses \
  -X POST \
  -H "Authorization: Bearer $DGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-4o",
  "instructions": "You are a concise assistant. Answer in German.",
  "input": "",
  "stream": false,
  "temperature": 0,
  "max_output_tokens": 0,
  "tools": [
    {
      "type": "function",
      "name": "string"
    }
  ],
  "tool_choice": "auto",
  "parallel_tool_calls": true,
  "text": {},
  "reasoning": {},
  "previous_response_id": "string",
  "store": true,
  "prompt_cache_key": "conversation-42",
  "reasoning_effort": "none"
}'

Request body

modelstringrequired

Model ID to use (e.g. gpt-4o, o4-mini). Use /v2/models to list available models.

instructionsstring | nulloptional

A system (or developer) message inserted as the first item in the model's context. The equivalent of a system message on /v2/chat/completions. If your input array already contains a system or developer item, this text is prepended to it — the endpoint supports one system message per request.

inputstring | object[]optional

Text, image, or file inputs. Pass a string for a single user turn or an array of input items for multi-turn conversations.

streambooleanoptional

Stream the response as server-sent events. Events are JSON objects with a type field (e.g. response.output_text.delta, response.completed).

temperaturenumberoptional

Sampling temperature (0–2). Higher = more varied output.

max_output_tokensintegeroptional

Upper bound on tokens to generate. Alias: max_completion_tokens. If you send no limit, most models may write up to their maximum output length.

toolsobject[]optional

Functions the model may call, in the flat Responses format. A function in the Chat Completions format ({"type": "function", "function": {"name": …, "parameters": …}}) is accepted too and read the same way. Without parameters (or with null) the function takes no arguments. A function tool that is still unusable, for example without a name, is answered with HTTP 400 invalid_request_error, and error.param names the field (tools[0].name). Built-in tool types such as web_search or local_shell are accepted for client compatibility and not offered to the model.

typestringrequired
namestringrequired
descriptionstringoptional
parametersobjectoptional

JSON Schema for function parameters. Optional: without it the function takes no arguments.

strictbooleanoptional
cache_controlCacheControloptional

Cache the tool definitions (and the system prompt with them, since Anthropic orders tools first). Requires a system message in the same request — with none, the marker is dropped rather than moved onto the first user turn, which would change every request and never produce a hit.

typestringrequired
ttlstringoptional

Cache lifetime. On THIS endpoint 1h is NOT SUPPORTED: it is accepted so an existing integration keeps working, but the breakpoint is placed with the default five-minute lifetime, billed at the five-minute cache-write rate (1.25x the input rate, not 2x), and reported as a marker_ttl_unsupported warning in prompt_cache. Because every breakpoint therefore has the same lifetime, mixing the two values is accepted and Anthropic's 1h-before-5m ordering rule is not enforced. 1h IS honoured on /anthropic/v1/messages, where cache_control is Anthropic's own field. Where nothing is cached the markers are ignored entirely.

tool_choicestring | objectoptional

Controls which (if any) tool is called.

parallel_tool_callsbooleanoptional

Allow the model to call multiple tools in a single turn.

textobjectoptional

Output format and verbosity configuration.

formatobject | objectoptional

Output format. Use json_schema for structured output (streaming not supported).

verbositystringoptional

Constrains response length. low = concise, high = detailed.

reasoningobjectoptional

Reasoning model configuration (for o3, o4-mini, etc.).

effortstringoptional

Reasoning intensity. none disables extended thinking and is forwarded to the model as such, so no reasoning tokens are generated or billed. Not every reasoning model accepts every value.

summarystring | nulloptional

Request a summary of the reasoning the model performed, returned as reasoning output items (and as response.reasoning_summary_* events when streaming). Only produced by reasoning models, and only when the effort is above none.

generate_summarystring | nulloptional

Deprecated alias for summary, accepted for older OpenAI SDKs. Prefer summary; if both are set, summary wins.

previous_response_idstring | nulloptional

Not supported: this API is stateless and keeps no earlier responses. A request that sets it is answered with 400 and error code previous_response_not_found; send the full conversation in input instead.

storebooleanoptional

Accepted for OpenAI-SDK compatibility but always treated as false — only stateless mode is supported. Setting true does not error; the response is still not stored.

prompt_cache_keystringoptional

Optional stable identifier for requests that share a prompt prefix — a conversation, session or workflow id. Raises the prompt-cache hit rate on models that cache prefixes automatically (Mistral). Ignored by models that cache on explicit cache_control breakpoints (Anthropic) and by models with no prompt cache. Your value is namespaced to your workspace server-side, so it can never collide with another tenant or aim at their cache. Hits are best-effort and never guaranteed — a miss is billed exactly like an uncached request, so there is nothing to lose by sending it. Do not put secrets or personal data in it.

reasoning_effortstringoptional

Alias for reasoning.effort, accepted so a /v2/chat/completions request body works unchanged on this endpoint. reasoning.effort wins if both are supplied.

Response

200application/json
{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 0,
  "status": "completed",
  "model": "string",
  "output": [
    {
      "id": "string",
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": null,
          "text": null,
          "annotations": null
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0,
    "total_tokens": 0,
    "input_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0
    }
  },
  "prompt_cache_key": "string"
}

Response object or SSE stream when stream: true

Also available as text/event-stream

idstring
objectstring
created_atinteger

Unix timestamp

statusstring
modelstring
outputobject[]
idstring
typestring
rolestring
contentobject[]
typestring
textstring
annotationsobject[]
usageobject
input_tokensinteger
output_tokensinteger
total_tokensinteger
input_tokens_detailsobject

The cache split of input_tokens, which is the INCLUSIVE total.

cached_tokensinteger

Input tokens served from the prompt cache, billed at the cache-read rate.

cache_write_tokensinteger

Input tokens written to the prompt cache.

prompt_cache_keystring | null

The prompt_cache_key you sent, echoed back. null when you sent none.

Response codes

200

Response object or SSE stream when stream: true

object
400

Invalid request or stream: true with json_schema

Error
401

Missing or invalid API key

Error
402

Insufficient credits

Error
403

Feature not enabled

Error
404

Model not found

Error
Was this page helpful?