API referenceReference / 04
Chat completions
OpenAI-compatible chat completions for every chat model.
POST https://api.routerplex.com/v1/chat/completions
The endpoint uses the OpenAI Chat Completions request and response shape, so the official SDKs work by changing the base URL and API key.
For the protocol boundary, portability limits, and provider-switching checklist, read What is an OpenAI-compatible API?.
python
import osfrom openai import OpenAIclient = OpenAI(base_url="https://api.routerplex.com/v1",api_key=os.environ["ROUTERPLEX_API_KEY"],)response = client.chat.completions.create(model="gemini-3.5-flash",messages=[{"role": "user", "content": "Explain HTTP in one line"}],)print(response.choices[0].message.content)
typescript
import OpenAI from "openai";const client = new OpenAI({baseURL: "https://api.routerplex.com/v1",apiKey: process.env.ROUTERPLEX_API_KEY,});const response = await client.chat.completions.create({model: "deepseek-v4-pro",messages: [{ role: "user", content: "Explain HTTP in one line" }],});console.log(response.choices[0].message.content);
Advanced parameters #
Function calling, tool use, JSON mode, and vision inputs work the same way as with OpenAI — pass tools, response_format, or image content parts as usual:
python
response = client.chat.completions.create(model="claude-sonnet-4-6",messages=[{"role": "user", "content": "What's the weather in Paris?"}],tools=[{"type": "function","function": {"name": "get_weather","parameters": {"type": "object","properties": {"city": {"type": "string"}},"required": ["city"],},},}],)
Support for tools/vision/JSON mode varies by model — frontier models (GPT, Claude, Gemini) support all three.