Skip to main content
Send chat completions to deployed models using the Adaptive SDK, OpenAI Python library, or any HTTP client. If you omit model, requests route to the project’s default model, or to a model in an active A/B test. Interactions (prompt + completion pairs) are logged automatically. See Interactions for details.

Chat completions

Streaming

Get the completion ID

Use completion_id to log Metrics against the response:

Vision requests

Models with the Multimodal tag accept images alongside text. Images must be base64-encoded data URIs (JPEG, PNG, WebP, or GIF, up to 10 MB each).

Structured output

Pass response_format to constrain a completion to a JSON Schema or a Pydantic model. For internal models, invalid tokens are masked at each generation step — the response is structurally guaranteed to parse. For external providers, the schema is forwarded to the provider’s native structured-output API.
response_format accepts a Pydantic BaseModel class, a raw JSON Schema envelope ({"type": "json_schema", "json_schema": {"name": ..., "schema": ...}}), or None (default). Pydantic models are auto-converted via model_json_schema() and patched for strict-mode compatibility (refs inlined, additionalProperties: false added).The response is a JSON string in response.choices[0].message.content — the SDK does not auto-deserialize. Call Model.model_validate_json(...) to get a typed instance.
Constrained decoding compiles the schema to a token-mask grammar. The compiler supports:
  • Types: string, integer, number, boolean, null, object, array, and union types via ["string", "null"] syntax
  • Composition: oneOf, anyOf, allOf (object merge only), $ref and $defs (inlined during SDK prep)
  • Strings: minLength, maxLength, pattern (regex), format, enum, const
  • Numbers: minimum, maximum, exclusiveMinimum, exclusiveMaximum. multipleOf requires explicit bounds — without bounds, it’s silently ignored.
  • Arrays: items, minItems, maxItems. Arrays must declare items.
  • Objects: properties, required, additionalProperties (false / true / schema)
Recursive schemas with cyclic $ref are unrolled to depth 4; deeper nesting is truncated. Format keywords without a regex equivalent are dropped.

Streaming with structured output

stream=True and response_format work together. Each chunk delivers partial JSON; buffer until the stream closes, then parse:

Failure modes

See SDK Reference for all chat methods.

OpenAI compatibility

Use the OpenAI Python library with your Adaptive deployment:
Set model to project_key/model_key. Use metadata instead of labels.
Multimodal image format differs between Adaptive and OpenAI:

HTTP requests

Use any HTTP client to call the chat completions endpoint directly.
See API Reference for the full endpoint specification.