OpenAI-Compatible APIs

ZettAgent mirrors the OpenAI REST surface so your existing SDK integrations work instantly.

Chat Completions

POST /v1/chat/completions

curl https://api.zettagent.com/v1/chat/completions \
  -H "Authorization: Bearer za_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "system", "content": "You are ZettAgent." },
      { "role": "user", "content": "Plan a robotics inspection workflow." }
    ],
    "stream": true
  }'

Streaming responses use text/event-stream with the same event schema as OpenAI.

Embeddings

POST /v1/embeddings

{
  "model": "text-embedding-3-large",
  "input": ["an agent observation"]
}

Routing Providers

Set LLM_PROVIDER=cf-ai to use Workers AI via AI Gateway, or LLM_PROVIDER=openai to forward requests to OpenAI using CF_OPENAI_API_KEY.

SDK Snippet (Node.js)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.ZA_API_KEY!,
  baseURL: "https://api.zettagent.com/v1",
});

const completion = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Design an onboarding agent." }],
});