d5a94947de
Co-authored-by: Copilot <copilot@github.com>
1.5 KiB
1.5 KiB
OpenRouter API Integration
Text Generation
Warning
TODO: Add more details on how the backend integrates with OpenRouter for text generation, including chat completions and single-prompt generation flows.
Image Generation
Image generation uses two different OpenRouter endpoints depending on the model:
- Legacy endpoint (
/images/generations): Used by DALL-E 3 and similar models. Returnsdata[].urlanddata[].b64_json. - Chat completions (
/chat/completionswithmodalities: ["image"]): Used by FLUX.2 Klein 4B and GPT-5 Image Mini. Returnschoices[0].message.images[].image_url.urlas base64 data URLs.
The router auto-detects the model type and routes accordingly. Image configuration (aspect_ratio, image_size) is passed via image_config for chat-based models.
Video Generation
Video generation uses OpenRouter's /api/v1/videos endpoint with a submit-and-poll pattern:
POST /api/v1/videoswithmodel,prompt,aspect_ratio,resolution,duration_seconds- Response:
{"id": "job_id", "polling_url": "https://..."}withstatus: "queued" - Poll
GET polling_urlevery 5 seconds untilstatusis"completed"or"failed" - Completed response includes
unsigned_urls: [str]array with video download URLs
Supported models: openai/sora-2-pro, google/veo-3.1-fast. Both text-to-video and image-to-video use the same /api/v1/videos endpoint (image-to-video includes image_url in the request body).