Guides

OpenAI compatibility

What is identical, what differs, and how to migrate an existing OpenAI integration.

Stac implements the OpenAI chat completions surface. Most integrations migrate by changing the base URL and the key.

client.tsdiff
  const client = new OpenAI({
-   baseURL: "https://api.openai.com/v1",
-   apiKey: process.env.OPENAI_API_KEY,
+   baseURL: "https://api.trystac.com/v1",
+   apiKey: process.env.STAC_API_KEY,
  });

Supported

FeatureStatus
POST /v1/chat/completionsFull
POST /v1/completionsFull
POST /v1/embeddingsFull
POST /v1/responsesFull
GET /v1/modelsFull
Streaming (SSE)Full
temperature, top_p, max_tokens, stopFull
Function / tool callingFull
JSON mode (response_format)Full
Vision inputsModel-dependent — check capabilities on GET /v1/models
Assistants, threads, filesNot supported

Differences that matter

  • model is always ignored. Your stack has exactly one model assigned; any value you send is replaced with it. GET /v1/models reports the real id, mostly for logging.
  • n is capped at 1. Multiple completions per request would multiply capacity use without a per-token meter to price it.
  • max_tokens has a floor. Requests are clamped to at least 8000 and at most 16000 — see Chat completions.
  • logit_bias is dropped, and message roles outside system, user, assistant, tool are discarded rather than rejected.
  • Rate limiting is per key, not per tier. See Errors & rate limits.

CLI tools

Codex CLI

Codex reads your key from whatever environment variable env_key names in its config — set that variable, then point Codex at Stac in ~/.codex/config.toml:

bash
export STAC_API_KEY="your-stac-api-key"
codex

Don't set model_context_window — a known Codex bug (openai/codex#16068) makes that key break auto-compaction permanently after the first overflow. Use only model_auto_compact_token_limit.

Cursor, Cline, Continue, and other OpenAI-compatible tools

Any tool with an "OpenAI compatible" provider setting works the same way:

  • Base URL: https://api.trystac.com/v1
  • API key: your Stac API key
  • Model: any value — it's ignored