API Integration
CoreRouter supports multiple common API styles. Most OpenAI-compatible SDKs or frameworks only require three configuration changes:
| Configuration | Value |
|---|---|
| API Key | sk-... created in console |
| Base URL | https://api.corerouter.cloud/v1 |
| Model ID | Model ID from console, e.g., claude-sonnet-4-5 |
Choose Integration Method
- curl: No SDK installation required. Ideal for troubleshooting API Keys, network issues, and Model IDs.
- Endpoints & Capabilities Overview: Select Endpoint, Base URL, and model capabilities by use case.
- Alpha Search API: Dedicated search endpoint for specific Agents or coding tools.
- Python: Using the OpenAI Python SDK.
- Node.js: Using the OpenAI Node.js SDK for JavaScript or TypeScript.
- LangChain: For LangChain applications, Chains, Agents, or RAG.
- Go HTTP: Direct API calls using Go's standard library.
API Types
| Use Case | Documentation | Base URL |
|---|---|---|
| Chat, Tool Calling, Vision | Chat Completions / SDK | https://api.corerouter.cloud/v1 |
| Legacy Text Completion | Moderations & Legacy Completions | https://api.corerouter.cloud/v1 |
| Agent, Codex, Responses Workflow | Responses API | https://api.corerouter.cloud/v1, model must support Responses |
| Agent Standalone Search | Alpha Search API | https://api.corerouter.cloud/v1, conditional support |
| Realtime Low-Latency Voice/Text | Realtime WebSocket | wss://api.corerouter.cloud/v1/realtime?model=... |
| Claude Code, Anthropic-Style Tools | Anthropic Messages | https://api.corerouter.cloud |
| Gemini API Client | Gemini API | https://api.corerouter.cloud |
| RAG, Vector Search | Embeddings | https://api.corerouter.cloud/v1 |
| RAG Document Reranking | Rerank | https://api.corerouter.cloud/v1 |
| Content Moderation | Moderations & Legacy Completions | https://api.corerouter.cloud/v1 |
| Images, standard audio (compatible model required) | Image & Audio APIs | https://api.corerouter.cloud/v1 |
| Novita text-to-speech | Speech plugin | https://api.corerouter.cloud, full path /novita/audio/speech |
| ElevenLabs text-to-speech | Multilingual V2 | https://api.corerouter.cloud, full path /novita/elevenlabs/speech |
| Video Generation, Task Polling | Video & Async Tasks | https://api.corerouter.cloud/v1 |
If your client automatically appends /v1/chat/completions, /v1/messages, or Gemini paths, use the root Base URL. If you see /v1/v1 or duplicate paths, the Base URL format doesn't match your client's expectations.
Recommended Environment Variables
Never hardcode API Keys in source code. Use environment variables on your local machine or deployment platform:
export COREROUTER_API_KEY="sk-xxxxxxxxxxxxxxxx"
export COREROUTER_BASE_URL="https://api.corerouter.cloud/v1"
export COREROUTER_MODEL="claude-sonnet-4-5"If using a .env file, ensure it's not committed to Git:
.env
.env.localMinimal Examples
Python
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["COREROUTER_API_KEY"],
base_url="https://api.corerouter.cloud/v1",
)
completion = client.chat.completions.create(
model="claude-sonnet-4-5",
messages=[
{"role": "user", "content": "Hello, please introduce yourself."}
],
)
print(completion.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.COREROUTER_API_KEY,
baseURL: "https://api.corerouter.cloud/v1",
});
const completion = await client.chat.completions.create({
model: "claude-sonnet-4-5",
messages: [
{ role: "user", content: "Hello, please introduce yourself." },
],
});
console.log(completion.choices[0].message.content);Feature Support
CoreRouter can forward text chat, streaming, tool calling, vision, embeddings, image, and audio capabilities. Available features depend on the selected model and upstream provider. Refer to the console for model-specific capabilities.
Common Endpoints:
| Capability | Endpoint |
|---|---|
| Model List | GET /v1/models |
| Gemini Model List | GET /v1beta/models |
| Gemini OpenAI-Style Model List | GET /v1beta/openai/models |
| Chat | POST /v1/chat/completions |
| Responses | POST /v1/responses |
| Responses Compact | POST /v1/responses/compact |
| Alpha Search | POST /v1/alpha/search |
| Anthropic Messages | POST /v1/messages |
| Gemini | POST /v1beta/models/{model}:generateContent |
| Embeddings | POST /v1/embeddings |
| Rerank | POST /v1/rerank |
| Moderations | POST /v1/moderations |
| Images | POST /v1/images/generations, POST /v1/images/edits |
| Standard audio (separate setup required) | POST /v1/audio/transcriptions, POST /v1/audio/translations, POST /v1/audio/speech |
| Novita text-to-speech | POST /novita/audio/speech, model minimax-speech-2.8-turbo |
| ElevenLabs text-to-speech | POST /novita/elevenlabs/speech, model elevenlabs-tts-multilingual-v2 |
| Realtime | GET /v1/realtime?model=... WebSocket |
| Video Tasks | POST /v1/videos, GET /v1/videos/{task_id} |
See Endpoints & Capabilities Overview for complete details.
Model Selection
- Chat: Select any available chat model from the console.
- Agent / Coding Tools: Prefer models with Tool Calling, Streaming, long context, and Coding Agent support.
- Codex / Responses: Must use a model that supports Responses from the console; standard chat models cannot be used directly as Responses models.
- Vision: Select models with image input support.
- Embeddings: Use Embeddings models, not chat model IDs.
- Rerank: Use Rerank models, not chat model IDs.
- Moderations: Select moderation models or confirm the default moderation model is available.
- Realtime: Select Realtime models and use WebSocket connections.
- Image, Audio, Video: Select models with the corresponding capabilities from the console, and note size, count, duration, and format limits.
Troubleshooting Steps
- Test with curl using the same API Key and Model ID.
- Confirm Base URL is
https://api.corerouter.cloud/v1for OpenAI-compatible endpoints. - Confirm the Header is
Authorization: Bearer sk-.... - Confirm the Model ID comes directly from the console, not display names.
- Check account balance, API Key permissions, model permissions, IP restrictions, and rate limits.
- If still failing, see Troubleshooting & FAQ.
