OpenAI integration
Call OpenAI through the ACE gateway: endpoint, zero-trust credential headers, stored-key alternative and runnable examples.
Send OpenAI traffic to https://engine.acefleet.dev/v1/chat/completions with your ACE developer key in Authorization: Bearer ace_dev_... and the provider credential on the zero-trust headers below. The request body is the vendor's own, relayed as written, and the vendor's answer comes back verbatim.
The same headers also serve:
https://engine.acefleet.dev/v1/responses
Zero-trust headers
| Header | Required | What it carries |
|---|---|---|
x-ace-openai-key |
yes | Upstream OpenAI key — or the key of whichever OpenAI-compatible host x-ace-openai-base-url points at. Used for this call only, never persisted or logged. |
x-ace-openai-base-url |
situational | Any OpenAI-compatible host (OpenRouter, Together, Groq, a self-hosted vLLM) is this channel pointed somewhere else: set the host here, its key above, and send its own model slug — anthropic/claude-sonnet-4.5 reaches OpenRouter spelled exactly like that. x-ace-served-by still names the channel (openai), not the host. |
Stored key instead
A stored openai vendor key replaces x-ace-openai-key; a stored endpoint on it replaces x-ace-openai-base-url.
Example request
curl -X POST https://engine.acefleet.dev/v1/chat/completions \
-H "Authorization: Bearer ace_dev_<your-dev-key>" \
-H "x-ace-openai-key: sk-proj-..." \
-H "Content-Type: application/json" \
-d '{ "model": "gpt-4o", "messages": [{ "role": "user", "content": "ping" }] }'
# The same channel, pointed at OpenRouter (or any OpenAI-compatible host):
curl -X POST https://engine.acefleet.dev/v1/chat/completions \
-H "Authorization: Bearer ace_dev_<your-dev-key>" \
-H "x-ace-provider: openai" \
-H "x-ace-openai-base-url: https://openrouter.ai/api/v1" \
-H "x-ace-openai-key: sk-or-v1-..." \
-H "Content-Type: application/json" \
-d '{ "model": "anthropic/claude-sonnet-4.5", "messages": [{ "role": "user", "content": "ping" }] }'
Quickstarts
OpenAI SDK (Python)
import openai
client = openai.OpenAI(
base_url="https://engine.acefleet.dev/v1",
api_key="ace_dev_<your-dev-key>",
default_headers={
"x-ace-openai-key": "sk-proj-...", # Zero-Trust header mode
},
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Analyze cluster telemetry."}],
)
print(response.choices[0].message.content)
OpenAI proxy (cURL)
curl -X POST https://engine.acefleet.dev/v1/chat/completions \
-H "Authorization: Bearer ace_dev_<your-dev-key>" \
-H "x-ace-openai-key: sk-proj-..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{ "role": "user", "content": "Analyze cluster telemetry." }]
}'
OpenAI Responses API (Python)
from openai import OpenAI
client = OpenAI(
base_url="https://engine.acefleet.dev/v1",
api_key="ace_dev_<your-dev-key>",
default_headers={
"x-ace-openai-key": "sk-proj-...", # Zero-Trust header mode
},
)
# Item-based, not message-based. store=False + include=[...] keeps reasoning
# continuity across turns without OpenAI retaining the conversation.
response = client.responses.create(
model="gpt-5",
instructions="You are a concise assistant.",
input=[{"role": "user", "content": [{"type": "input_text", "text": "Analyze cluster telemetry."}]}],
reasoning={"effort": "medium", "summary": "auto"},
store=False,
include=["reasoning.encrypted_content"],
)
print(response.output_text)
Vercel AI SDK: OpenAI and Azure (@ai-sdk/openai, @ai-sdk/azure)
Both default to the Responses API, which the gateway serves as its own surface — /v1/responses, and under /azure/openai the three spellings the Azure SDKs use — with the item array, reasoning, store, include and encrypted_content relayed as sent and the response.* stream returned verbatim; chat completions from the same factories land on /v1/chat/completions and /azure/openai/deployments/{deployment}/chat/completions. @ai-sdk/openai sends apiKey as Authorization: Bearer; @ai-sdk/azure sends it as api-key, which the Azure surface reads the same way. Azure has no global host, so the resource endpoint travels on x-ace-azure-endpoint and the deployment name is the model.
import { createOpenAI } from '@ai-sdk/openai';
import { createAzure } from '@ai-sdk/azure';
const openai = createOpenAI({
baseURL: 'https://engine.acefleet.dev/v1',
apiKey: 'ace_dev_<your-dev-key>', // Authorization: Bearer
headers: { 'x-ace-openai-key': 'sk-proj-...' },
});
const azure = createAzure({
baseURL: 'https://engine.acefleet.dev/azure/openai',
apiKey: 'ace_dev_<your-dev-key>', // sent as api-key
headers: {
'x-ace-provider': 'azure',
'x-ace-azure-key': '<your-azure-key>',
'x-ace-azure-endpoint': 'https://<resource>.openai.azure.com',
},
});
// model: azure('gpt-4o-prod') — the deployment name