Chat Completions
Connect chat models through an OpenAI-compatible messages interface.
Request structure
Send model and messages to POST /v1/chat/completions. Use a direct ID authorized for the key or a logical model from its bound Policy. Messages contain roles and content. Check operation capabilities before using tools or multimodal input.
Request example
After setup and publishing, set SHIELDON_GATEWAY_BASE_URL (including /v1) and SHIELDON_GATEWAY_API_KEY in your server environment. Replace the example model with an ID returned by GET /v1/models. cURL examples use Bash syntax.
curl "$SHIELDON_GATEWAY_BASE_URL/chat/completions" \
-H "Authorization: Bearer $SHIELDON_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "@your-integration/your-model",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'Streaming responses
Set stream: true to consume incremental SSE events. Clients must handle disconnections, cancellation, and partial output. Retrying after output has started can duplicate content and incur additional usage.
This example reuses the client above. Blocking output guardrails are incompatible with streaming and reject the request before calling the Provider.
stream = client.chat.completions.create(
model="@your-integration/your-model",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
with stream:
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="")