Call API endpoints
Chat, Responses, Messages, images, embeddings, audio, video, and web search. Availability depends on your connected accounts and provider capabilities.
These are routes supported by the router, not a promise that every endpoint is enabled for your account. Examples are commands for you to run; this page does not send API requests. Replace every YOUR_* placeholder and keep your key out of frontend code.
export LAROUTER_API_KEY="YOUR_API_KEY"Models and capabilities
Discover IDs, then select a model supported by your accounts and task type. A catalog entry does not guarantee availability for your key.
| Method | Endpoint | Usage |
|---|---|---|
| GET | /v1/models | Model catalog |
| GET | /v1/models/{kind} | Filter by image, tts, stt, embedding, image-to-text, or web |
| GET | /v1/models/info?id={modelId} | Single-model metadata; optional kind filter |
curl https://i-larouter.lapage.vn/v1/models \
-H "Authorization: Bearer $LAROUTER_API_KEY"curl https://i-larouter.lapage.vn/v1/models/image \
-H "Authorization: Bearer $LAROUTER_API_KEY"Chat, Responses and Messages
Choose the protocol your application uses. LaRouter provides Chat Completions; there is no legacy /v1/completions route. Streaming, tool calling, and context compaction depend on the provider/model.
| Method | Endpoint | Usage |
|---|---|---|
| POST | /v1/chat/completions | model + messages |
| POST | /v1/responses | model + input |
| POST | /v1/responses/compact | Compact conversation input through the Responses pipeline |
| POST | /v1/messages | model + max_tokens + messages |
| POST | /v1/messages/count_tokens | Character-based token estimate, not an exact tokenizer |
curl https://i-larouter.lapage.vn/v1/chat/completions \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_ID","messages":[{"role":"user","content":"Hello"}]}'curl https://i-larouter.lapage.vn/v1/responses \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_ID","input":"Hello"}'curl https://i-larouter.lapage.vn/v1/messages \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_ID","max_tokens":256,"messages":[{"role":"user","content":"Hello"}]}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["LAROUTER_API_KEY"],
base_url="https://i-larouter.lapage.vn/v1",
)
result = client.chat.completions.create(
model="YOUR_MODEL_ID",
messages=[{"role": "user", "content": "Hello"}],
)
print(result.choices[0].message.content)For Python, install the openai package first. All examples read your API key from an environment variable on a server or trusted local machine.
Image generation and editing
Requires an image-capable provider/account. Choose from /v1/models/image and confirm the model’s input format. This router’s /images/edits route accepts JSON; it is not a universal multipart upload endpoint.
| Method | Endpoint | Usage |
|---|---|---|
| POST | /v1/images/generations | model + prompt |
| POST | /v1/images/edits | JSON prompt and provider-specific image fields |
curl https://i-larouter.lapage.vn/v1/images/generations \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_IMAGE_MODEL_ID","prompt":"A quiet garden at sunrise"}'curl https://i-larouter.lapage.vn/v1/images/edits \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_CODEX_IMAGE_MODEL_ID","prompt":"Make the background lighter","image":"https://YOUR_IMAGE_HOST/reference.png"}'Output format, size, count, and editing support depend on the provider. A Codex Plus account does not imply access to every image operation. The editing example uses Codex’s image field with a reference URL accessible to the provider.
Embeddings
Convert text to vectors with a supported embedding model. A chat model is not a substitute for an embedding model.
| Method | Endpoint | Usage |
|---|---|---|
| POST | /v1/embeddings | model + input |
curl https://i-larouter.lapage.vn/v1/embeddings \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_EMBEDDING_MODEL_ID","input":"A short text to index"}'Audio
TTS and STT require matching providers. Choose a supported model/voice; file limits, languages, and formats depend on the provider.
| Method | Endpoint | Usage |
|---|---|---|
| POST | /v1/audio/speech | model + input |
| POST | /v1/audio/transcriptions | multipart: model and file |
| GET | /v1/audio/voices?provider={provider} | Voices for elevenlabs, deepgram, inworld, edge-tts, local-device |
curl https://i-larouter.lapage.vn/v1/audio/speech \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_TTS_MODEL_OR_VOICE_ID","input":"Hello from LaRouter"}' \
--output speech.mp3curl https://i-larouter.lapage.vn/v1/audio/transcriptions \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-F "model=YOUR_STT_MODEL_ID" \
-F "[email protected]"This router returns audio by default from speech; use ?response_format=json for its supported JSON response. A voice may be encoded in the model ID itself.
Asynchronous video
Video routes forward jobs to a supported video provider; the source includes xAI Grok Imagine integration. Your account needs video access; model combos are unsupported.
| Method | Endpoint | Usage |
|---|---|---|
| POST | /v1/videos/generations | Create a video job |
| POST | /v1/videos/edits | Edit a video with a provider-specific payload |
| POST | /v1/videos/extensions | Extend a video with a provider-specific payload |
| GET | /v1/videos/{id} | Poll a job status |
curl --include https://i-larouter.lapage.vn/v1/videos/generations \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_VIDEO_MODEL_ID","prompt":"A slow pan across a quiet garden"}'curl https://i-larouter.lapage.vn/v1/videos/YOUR_JOB_ID \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "x-connection-id: CONNECTION_ID_FROM_CREATE_RESPONSE"Save the job ID and x-9router-connection-id response header from creation. Echo that header’s value as x-connection-id when polling to use the same account. Duration, source media fields, and response states are provider-specific.
Web search and fetch
Requires a search or fetch provider. Use a configured provider ID rather than assuming a chat model supports these endpoints.
| Method | Endpoint | Usage |
|---|---|---|
| POST | /v1/search | provider (or model) + query |
| POST | /v1/web/fetch | provider (or model) + url |
| POST | /v1/alpha/search | Codex-specific search protocol |
curl https://i-larouter.lapage.vn/v1/search \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"provider":"YOUR_SEARCH_PROVIDER_ID","query":"Latest documentation","max_results":5}'curl https://i-larouter.lapage.vn/v1/web/fetch \
-H "Authorization: Bearer $LAROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"provider":"YOUR_FETCH_PROVIDER_ID","url":"https://example.com"}'/alpha/search is for Codex-protocol clients; it is not a drop-in replacement for the /search query payload.