API docsGet started
Agent integration
Give this documentation URL to your coding agent to integrate the full 01router multi-model workflow: configure a connection, discover models and their fields/prices, estimate credits, submit requests, and poll results.
Live base URL
https://01router.com/api/v1Sandbox base URL
https://01router.com/api/sandbox/v1Request
Documentation URL for your agent
https://01router.com/docs/llms-full.txt?locale=en§ion=agentCopy this prompt to your agent
Read https://01router.com/docs/llms-full.txt?locale=en§ion=agent and integrate the complete 01router multi-model workflow into this application. Connection settings are Base URL, API Key, and optional Project ID; do not configure a fixed model. Fetch models dynamically: omit project for the full platform catalog, or send project for models available under that project configuration. Implement model selection, field and price discovery, credit estimation from user input, request submission, and result polling. Refresh the parameter form and quote when models change. Reuse the existing stack, keep credentials server-side, distinguish live catalog/quote validation from sandbox simulation, and report changed files, configuration steps, and actual verification coverage.Example server-side environment variables
ROUTER01_BASE_URL=https://01router.com/api/v1
ROUTER01_API_KEY=YOUR_PROJECT_API_KEY
ROUTER01_PROJECT_ID=Complete integration flow (paths relative to Base URL)
Configure Base URL + API Key + optional Project ID
↓
GET /models No project: full platform catalog
GET /models?project=PROJECT_ID With project: available project models
↓ User selects a model (slug)
GET /models/MODEL_SLUG Platform model: fields, providers, prices
Selected entry in project data Project model: params, prices, provider
↓ Generate the form; user fills input
POST /quote Estimate credits and cost, no charge
↓ User confirms current inputs and quote
POST /generations Submit model, input, optional project/provider
↓ Save returned id
GET /generations/ID Poll at least 3 seconds apart until succeeded/failed
↓
Display outputs or error, plus actual credits / price_usd
Quotes and submissions use the runtime-selected model; omit project when unset.
Chat uses POST /chat/completions with JSON/SSE responses, without generation polling.Usage notes
- Before starting: the user supplies only Base URL, API Key, and optional Project ID. Obtain the project ID and key at https://01router.com/settings/projects. Do not require a fixed model ID: model comes from runtime selection. If the key is missing, implement public catalog, configuration, and quote flows first, then use a placeholder for sandbox tasks. The user enters real credentials in system settings, never in the conversation or logs.
- 1. Inspect the target project: read its instructions, dependency manifest, environment configuration, existing AI clients, server routes, and relevant UI. Reuse its architecture and libraries. Identify the requested user flow and ask about requirements only when the project does not establish them.
- 2. Configure the connection: read ROUTER01_BASE_URL, ROUTER01_API_KEY, and optional ROUTER01_PROJECT_ID (or equivalent system settings). Use the service /api/v1 base URL and append endpoint paths once. When Project ID is empty, omit project entirely, including ?project=; when set, send it as the catalog query parameter and as the JSON project field for quotes and submissions. Protected endpoints require Authorization: Bearer <key>; JSON bodies require Content-Type: application/json. Store the API key only in server-side environment files or secret storage, never browser bundles, public-prefixed variables, or logs.
- 3. Discover models dynamically: read endpoint references from https://01router.com/docs/llms.txt?locale=en. Without Project ID, GET https://01router.com/api/v1/models returns all platform models. With Project ID, GET https://01router.com/api/v1/models?project=PROJECT_ID returns models available under that project configuration (including platform models when All models is enabled). Read the data array and optionally filter with type. Use slug as the selection value and display name and type. Refresh the catalog and clear invalid selections when the project changes; never hardcode a model list. Catalogs are public, but execution remains restricted by the API key’s project. A configured Project ID must match the key.
- 4. Load the selected model’s fields and prices: without Project ID, GET /models/MODEL_SLUG provides params, providers[].params, providers[].prices, fromMicros, and fromUnit. With Project ID, use the complete matching slug entry from the project catalog, including params, prices, provider, fromMicros, and fromUnit. The current /models/MODEL_SLUG endpoint only looks up platform models; it does not support project filtering or custom project slugs. Generate and validate forms using param name, type, required, default, options, min, max, maxItems, and maxLength. For an explicitly selected platform provider, use its parameter constraints. Clear incompatible fields when switching models. Price rules contain unit, conditions, and priceMicros; USD equals priceMicros / 1,000,000. fromMicros is a starting unit price, not a request total.
- 5. Estimate generation credits: after model selection and parameter entry, POST to the live API /quote with model (the selected slug) and input (form values). Include project when configured and provider when explicitly selected. No API key or charge is required. Read credits, price_usd, unit, and quantity from providers and display unavailable reasons. Debounce requoting on input changes and ignore stale responses. Providers are sorted by price; the first is the default candidate if none is selected. If users select a quote, preserve its model, inputs, and provider on submission; project-pinned providers take precedence. Quotes estimate platform charges, while project catalog prices may include a resale ratio. Keep these distinct and never hardcode a USD-to-credit conversion. Final credits and price_usd come from the actual task. Chat settles against actual token usage; generation quotes are not final chat charges.
- 6. Submit requests: image, video, and audio use POST /generations with the current quoted model and input, plus project/provider where applicable. Select model at runtime, never from a fixed environment variable. API keys automatically select their own project, so project may be omitted; if supplied, it must match the key or the request returns 403. Persist the returned id and status and prevent duplicate submissions. Chat uses POST /chat/completions with model, messages, and applicable project/provider, handling JSON or stream=true SSE; chat does not use generation polling. Use the /images/generations reference when synchronous image responses are needed.
- 7. Poll results: GET /generations/ID with the same API key at intervals of at least 3 seconds and with an overall timeout. Continue for queued/processing, display outputs, credits, and price_usd on succeeded, and stop with error on failed. Persist IDs so restored pages resume existing tasks. Stopping polling does not cancel a task. If synchronous image generation returns 504 with error.id, poll that ID instead of resubmitting.
- 8. Handle errors: read error.message and error.code on non-2xx responses. Handle authentication (401), balance (402), permission (403), invalid parameters (400), missing models/projects (404), and rate limits (429). Apply bounded backoff to retryable reads. Never blindly retry generation creation or chat requests after ambiguous network failures, which may duplicate work and charges.
- 9. Verify in stages: use the live API to check catalogs with and without a project, dynamic fields, price display, and /quote (these public reads and quotes incur no charge). Then read https://01router.com/docs/llms-full.txt?locale=en§ion=sandbox and use the sandbox at https://01router.com/api/sandbox/v1 for submission, polling, and X-Sandbox-Error flows; sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx is a format-valid placeholder when no real key is available. The sandbox does not support /quote or simulate project mappings/restrictions, model-specific validation, or real prices; it cannot validate those behaviors. Check model switching, quote refresh after parameter changes, success/failure terminal states, and polling timeouts.
- 10. Deliver the complete flow: run relevant checks allowed by the target project, document the three connection settings (Project ID optional) and usage, and report changed files and verified steps. The live Base URL is https://01router.com/api/v1; sandbox URLs are for simulation only. Confirm authorization and a valid key before paid live calls, keep sandbox/live task IDs separate, and explicitly report unverified behavior instead of treating simulated output as production success.
Use with AI
Give your coding assistant the documentation index or the full API reference, including live model parameters.