Codex CLI
Install with npm install -g @openai/codex. Start with environment variables: OPENAI_API_KEY=sk-om-... and OPENAI_BASE_URL=https://api.openmagic.ai/v1. First task: ask it to inspect a small folder and explain before editing.
OpenMagic API needs to meet users where they already work: Claude Code, Codex, Cursor, Cline, SDKs, and lightweight local tools.
Use these unless a client explicitly asks for a different endpoint field.
| Field | Value |
|---|---|
| Base URL | https://api.openmagic.ai/v1 |
| API key | Your OpenMagic console key |
| Chat model | gpt-4o-mini or another model listed on /models |
| Compatibility | OpenAI-compatible chat/completions route |
# OpenAI SDK / generic compatible clients OPENAI_API_KEY=sk-om-... OPENAI_BASE_URL=https://api.openmagic.ai/v1
Install with npm install -g @openai/codex. Start with environment variables: OPENAI_API_KEY=sk-om-... and OPENAI_BASE_URL=https://api.openmagic.ai/v1. First task: ask it to inspect a small folder and explain before editing.
If the CLI supports OpenAI-compatible providers, use the same two fields: API key and base URL. Prefer gpt-4o-mini for the first run, then switch to stronger coding models after usage is visible in Console.
Cline CLI supports an OpenAI provider with custom base URL. Use cline auth -p openai -k sk-om-... -b https://api.openmagic.ai/v1. In VS Code, choose OpenAI-compatible provider and fill the same fields.
Open Roo settings, select OpenAI Compatible, set Base URL to https://api.openmagic.ai/v1, API Key to your OpenMagic key, and Model ID to a supported model. If model dropdown is empty, type the model manually.
Use provider openai and set apiBase to https://api.openmagic.ai/v1. Configure separate models for chat/autocomplete later; first verify chat with one model.
Use custom OpenAI-compatible settings if your version exposes Base URL. Paste the OpenMagic key, set model name manually if needed, and run a short prompt before using Composer on a whole repo.
For self-hosted web chat, set server-side OpenAI key to your OpenMagic key and OpenAI proxy/base URL to https://api.openmagic.ai/v1. Keep access code enabled if the app is public.
Claude Code installs with Anthropic's package and supports ANTHROPIC_BASE_URL. Use ANTHROPIC_BASE_URL=https://api.openmagic.ai/anthropic and ANTHROPIC_API_KEY=sk-om-.... This route accepts Anthropic Messages format and converts it to the OpenMagic gateway internally.
Some versions expose only official BYOK and not custom Base URL. If your version has custom OpenAI-compatible Base URL, use https://api.openmagic.ai/v1; otherwise it cannot directly route to OpenMagic.
Start safe; increase limits only after the first task succeeds.
| Setting | Beginner value | Why |
|---|---|---|
| Model | gpt-4o-mini | Cheap smoke test before stronger routes. |
| Max output tokens | 1024-2048 | Enough for explanations, avoids runaway output. |
| Temperature | 0.2-0.5 | More stable for coding tasks. |
| Context / max input | Use tool default first | Only raise it when the tool reports context overflow. |
| First task scope | One folder or one bug | Avoid whole-repo rewrites on first run. |
curl https://api.openmagic.ai/v1/chat/completions \
-H "Authorization: Bearer sk-om-..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Reply with only OK."}],
"max_tokens": 10
}'Most first-call failures fall into these buckets.
| Symptom | Check |
|---|---|
| 401 unauthorized | Confirm the key is copied from OpenMagic console and sent as Bearer token. |
| 404 or wrong route | Use https://api.openmagic.ai/v1, not the marketing homepage URL. |
| Model not found | Use a model from /models or your assigned route group. |
| Quota exhausted | Open Console > Billing to recharge or buy a monthly quota plan. |