Skip to main content
Menu
Build / Text completions
Build

Text completions

Send a prompt and get text back on the legacy completions endpoint, for code written before chat completions.

3 minute readUpdated 15 November 2026curl · Python · TypeScript

When to use it#

POST /v1/completions is the legacy endpoint: a prompt goes in and text comes out. It takes models of kind completion or chat. Prefer chat completions for new code.

Completions are served Routed only: no supplier signs completion responses, so there is nothing to verify a Sealed answer against. A request for the Sealed tier (by panward-tier, or by default) is refused with 400 unsupported_parameter naming panward-tier, before any upstream call; use chat completions for Sealed traffic. The samples on this page send panward-tier: routed.

Request#

The OpenAI SDKs' completions call works with the base URL and key changed. Unknown fields are refused with 400 invalid_request.

curl https://api.panward.ai/v1/completions \
  -H "Authorization: Bearer $PANWARD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "panward-tier: routed" \
  -d '{
    "model": "z-ai/glm-5.3",
    "prompt": "Discharge summary:",
    "max_tokens": 200,
    "temperature": 0.2,
    "stop": ["###"]
  }'
FieldRequiredValuesLimitsNotes
modelYesstring
promptYesstring | array of string
max_tokensNointegermin 1
temperatureNonumbermin 0; max 2
top_pNonumbermax 1
frequency_penaltyNonumbermin -2; max 2
presence_penaltyNonumbermin -2; max 2
seedNointeger
stopNostring | array of string
echoNoboolean
logprobsNointegermin 0; max 5
streamNoboolean
stream_optionsNoobjectOnly valid with `stream: true`.
userNostringmax length 256Accepted for compatibility and ignored. Never stored, never forwarded upstream.

Response#

The response is a text_completion object with a cmpl- id. Each choice has its text and a finish_reason, and usage holds the token counts that are billed.

A text_completion object
{
  "id": "cmpl-01JC7Q4N8G5T2R9X1M3K6P7W4D",
  "object": "text_completion",
  "created": 1790000000,
  "model": "z-ai/glm-5.3",
  "choices": [
    {
      "index": 0,
      "text": " The patient was admitted with community-acquired pneumonia.",
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 4,
    "completion_tokens": 12,
    "total_tokens": 16
  }
}

Streaming#

With stream: true the response uses the same event-stream framing as chat completions, with text_completion chunks that carry partial text, ended by data: [DONE]. Usage is sent only when stream_options.include_usage is true, in the final chunk.

Stream a text completion, with usage in the last chunk
curl -N https://api.panward.ai/v1/completions \
  -H "Authorization: Bearer $PANWARD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "panward-tier: routed" \
  -d '{
    "model": "z-ai/glm-5.3",
    "prompt": "Discharge summary:",
    "max_tokens": 200,
    "stream": true,
    "stream_options": {"include_usage": true}
  }'

The streaming page covers the frames, errors after the first byte and how to keep the raw stream for verification.

Headers, receipts and errors#

Text completions take the same request headers, routing, receipts and errors as chat completions: panward-tier, panward-fallback, panward-hold-until-verified and X-Request-Id on the request, and panward-receipt-id, panward-tier, panward-region and panward-model on the response (Tiers and routing headers, Receipts and verification, Errors).

Was this page helpful?Suggest an edit