{"repo": "chinmaymk/ra", "files": {"docs/site/providers/openai.md": {"785ac5d3571fdecf00109eae3bcf011f527098af": {"t": 1785674610.2446342, "n": 3449, "h": "fcfc10b65a918345", "c": "# OpenAI\n\nra ships two OpenAI providers — one for the **Responses API** (default) and one for the **Chat Completions API**.\n\n| Provider value | API | When to use |\n|----------------|-----|-------------|\n| `openai` | [Responses API](https://platform.openai.com/docs/api-reference/responses) | **Default.** Use with OpenAI directly. Supports native file inputs and structured streaming events. |\n| `openai-completions` | [Chat Completions API](https://platform.openai.com/docs/api-reference/chat) | Use with **OpenAI-compatible services** (Together AI, Fireworks, Groq, etc.) or if you specifically need the Chat Completions endpoint. |\n\n## Setup\n\n```bash\nexport OPENAI_API_KEY=sk-...\nra --provider openai \"Hello\"\n```\n\n## Environment variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `OPENAI_API_KEY` | Yes | OpenAI API key (used by both providers) |\n\n## Models\n\n| Model | Notes |\n|-------|-------|\n| `gpt-4.1` | Flagship model |\n| `gpt-4.1-mini` | Faster, cheaper |\n| `o3` | Reasoning model |\n| `o4-mini` | Reasoning, fast |\n\n```bash\nra --provider openai --model gpt-4.1 \"Explain this error\"\nra --provider openai --model o3 \"Solve this step by step\"\n```\n\n## Extended thinking\n\nSupported modes: `off`, `low`, `medium`, `high`, `adaptive`. Works with both providers.\n\n```bash\nra --provider openai --thinking high \"Solve this step by step\"\n```\n\n## OpenAI-compatible APIs (Chat Completions) {#compatible-apis}\n\nMost OpenAI-compatible services (Together AI, Fireworks, Groq, etc.) implement the **Chat Completions** endpoint, not the Responses API. Use `openai-completions` for these:\n\n```bash\n# Together AI\nexport OPENAI_API_KEY=your-together-key\nra --provider openai-completions \\\n --openai-base-url https://api.together.xyz/v1 \\\n --model meta-llama/Llama-3-70b-chat-hf \"Hello\"\n\n# Groq\nexport OPENAI_API_KEY=your-groq-key\nra --provider openai-completions \\\n --openai-base-url https://api.groq.com/openai/v1 \\\n --model llama-3.3-70b-versatile \"Hello\"\n\n# Fireworks\nexport OPENAI_API_KEY=your-fireworks-key\nra --provider openai-completions \\\n --openai-base-url https://api.fireworks.ai/inference/v1 \\\n --model accounts/fireworks/models/llama-v3p1-70b-instruct \"Hello\"\n```\n\nOr in a config file:\n\n```yaml\napp:\n providers:\n openai-completions:\n baseURL: https://api.together.xyz/v1\n apiKey: ${OPENAI_API_KEY}\n\nagent:\n provider: openai-completions\n model: meta-llama/Llama-3-70b-chat-hf\n```\n\n::: tip\nIf you use `--provider openai` with a third-party base URL and get errors, switch to `openai-completions` — the service likely doesn't support the Responses API.\n:::\n\n## Custom base URL (Responses API)\n\nIf you're using a proxy or gateway that supports the OpenAI Responses API:\n\n```bash\nra --provider openai --openai-base-url https://my-proxy.example.com/v1 \"Hello\"\n```\n\n## Choosing between the two providers\n\nUse **`openai`** (Responses API) when:\n- Calling OpenAI directly\n- Using a proxy that forwards to OpenAI's Responses endpoint\n- You need native file attachment support\n\nUse **`openai-completions`** (Chat Completions API) when:\n- Using a third-party OpenAI-compatible service (Together, Groq, Fireworks, etc.)\n- Calling an OpenAI-compatible local server (vLLM, llama.cpp server, etc.)\n- The endpoint only supports `/v1/chat/completions`\n\n## See also\n\n- [Context Control](/core/context-control) — extended thinking details\n- [Configuration](/configuration/) — provider credentials reference\n"}}}}