Console

BasicRouter Docs

Quickstart

BasicRouter gives production teams one stable API for model access, routing, fallback, usage tracking, and credit-based billing. LLM token supply is sourced from trusted enterprise cloud original-provider accounts, with privacy protection, high stability, and request traceability built into the gateway.

Base URLhttps://api.basicrouter.ai/api
OpenAI-compatiblehttps://api.basicrouter.ai/api/v1
Anthropic-messageshttps://api.basicrouter.ai/api/v1
AuthAuthorization: Bearer <key>

Create an API key

Create a BasicRouter API key in the console. Keep the key on your server and never expose it in browser or mobile client code.

Recommended key strategy:

Key typeRecommended usage
Development keyLocal development, staging, testing, and prototypes.
Production keyBackend production workloads only.
Integration keyDedicated key for tools such as Cursor, Claude Code, Codex, Hermes, or OpenClaw.
Customer / tenant keyOptional key isolation for enterprise customers, tenant traffic, or business units.

Rotate keys when team access changes. Revoke keys that are no longer used.

Point your SDK at BasicRouter

Most OpenAI-compatible clients only need a new base URL and API key.

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.BASICROUTER_API_KEY,
  baseURL: "https://api.basicrouter.ai/api/v1"
});

Send a chat completion

curl --request POST \
  --url https://api.basicrouter.ai/api/v1/chat/completions \
  --header "Authorization: Bearer $BASICROUTER_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "claude-sonnet-5",
    "messages": [
      { "role": "user", "content": "Explain BasicRouter in one sentence." }
    ]
  }'

Check usage and balance

curl --request GET \
  --url https://api.basicrouter.ai/api/v1/billing/balance \
  --header "Authorization: Bearer $BASICROUTER_API_KEY"

Model Discovery

Use the Models page or the Models API to inspect available text models. Model metadata includes vendor, serving provider, modality, context length, supported API families, supported capabilities, availability, account-level limits, and credit pricing.

Endpoint: GET /v1/models Purpose: List models available to the current account.

curl --request GET \
  --url https://api.basicrouter.ai/api/v1/models \
  --header "Authorization: Bearer $BASICROUTER_API_KEY"

Capability matrix

CapabilityDescriptionCommonly used by
streamingSupports server-sent event streaming.Chat apps, coding agents, real-time UX.
tool_callingSupports tool or function calling.Agents, workflow automation, coding assistants.
structured_outputsSupports schema-constrained or JSON outputs.Data extraction, workflow automation, enterprise apps.
json_modeCan return JSON-formatted output.Lightweight structured responses.
visionAccepts image input.Multimodal chat, UI analysis, document screenshots.
prompt_cachingSupports cached input or context reuse.Long-context agents, repeated system prompts.
reasoningSupports explicit reasoning controls where available.Complex planning, coding, analysis workflows.
logprobsSupports token probability output.Evaluation, ranking, advanced NLP workflows.

API family compatibility matrix

API familyTextVision inputTool callingStructured outputStreamingNotes
OpenAI Chat CompletionsYesModel-dependentModel-dependentModel-dependentYesBest default for OpenAI-compatible agents and SDKs.
OpenAI ResponsesYesModel-dependentModel-dependentModel-dependentYesRecommended for newer OpenAI-style agent workflows.
Anthropic MessagesYesModel-dependentModel-dependentModel-dependentYesBest for Claude-compatible clients and Claude Code.
Gemini OpenAI compatibilityYesModel-dependentModel-dependentModel-dependentYesUse Gemini models through OpenAI-style clients.
Gemini native compatibilityYesModel-dependentModel-dependentModel-dependentYesBest for existing Gemini-native applications.
BasicRouter image generationNoModel-dependentNoNoNoUses async task polling or webhook.
BasicRouter video generationNoModel-dependentNoNoNoUses async task polling or webhook.

Authentication

Every API request uses a bearer token. Store keys in server-side environment variables, rotate them when team access changes, and log request IDs for debugging.

HeaderValueNotes
AuthorizationBearer YOUR_API_KEYRequired for every request.
Content-Typeapplication/jsonRequired for JSON request bodies.

Key security recommendations

  1. Keep API keys on the server. Do not expose keys in browser or mobile client code.
  2. Use separate keys for development, staging, production, and third-party integrations.
  3. Scope keys by environment, service, customer, or tenant when available.
  4. Rotate keys after employee departures, vendor access changes, or suspected leakage.
  5. Store keys in secret managers or environment variables, not source code.

Using the Console

The BasicRouter Console is the operational control plane for API access, model availability, routing policies, usage visibility, and billing administration. It gives account administrators a centralized view of keys, models, requests, credits, and account-level controls for production model traffic.

Managing API keys

Create, rotate, revoke, and label API keys from the console. Use separate keys for development, staging, production, and individual services so usage can be audited and isolated by environment or application.

PracticeDescription
Separate environmentsUse different API keys for development, staging, and production traffic.
Use descriptive labelsLabel keys by application, service, environment, or integration.
Rotate regularlyRotate keys when access changes or credentials may have been exposed.
Avoid client-side exposureKeep API keys on server-side systems only. Do not expose keys in browser or mobile client code.
Monitor key usageReview request volume, credit consumption, and error patterns by key.

Model list

Use the Models page to review models available to the account. Each model entry may include vendor, serving provider, modality, supported API families, context length, capability flags, availability status, and pricing information.

FilterPurpose
VendorFilter by model vendor such as OpenAI, Anthropic, Google, Qwen, DeepSeek, or other providers.
ProviderFilter by serving provider or cloud provider.
ModalityFilter by text, image, video, embedding, audio, or multimodal support.
CapabilityFilter by streaming, tool calling, structured outputs, vision, prompt caching, or reasoning support.
AvailabilityIdentify models that are currently available to the account.

For production applications, verify model capabilities before enabling traffic. Some parameters and features are model-dependent and may not be supported across all API families.

Usage & logs

The Usage & Logs view provides operational visibility into API traffic. Teams can inspect request volume, selected models, resolved routing targets, credit consumption, latency, error codes, and request IDs.

  • Troubleshoot failed requests.
  • Identify high-cost workloads.
  • Compare model usage across applications and environments.
  • Validate routing and fallback behavior.
  • Investigate latency or provider availability issues.
  • Provide request IDs when contacting support.

Each API response includes or exposes a BasicRouter request ID. Store this ID in your application logs to make production debugging and support escalation more efficient.

Fallback

Fallback is BasicRouter's resilience mechanism. When the primary model or routing policy fails, the system automatically switches to a backup model to keep processing the request. This keeps your application responsive and minimizes the risk of service disruption.

High availability guarantee
Fallback acts like a safety net, keeping your application running smoothly even when a model failure, quota limit, or network fluctuation occurs.

Why fallback matters

In production, model services can run into a number of unpredictable issues:

  • Model service failure: the upstream API becomes temporarily unavailable or times out.
  • Performance fluctuation: high model load leads to slow or failed responses.
  • Routing failure: all candidate models selected by smart routing become unavailable.

Fallback keeps your application available by providing a reliable backup path.

Core advantages

AdvantageDescription
High availabilityAutomatic failover keeps the service running and reduces the impact of outages.
Transparent switchingThe system switches models automatically — no application code changes required.
Flexible configurationSupports both per-request and account-level configuration for different use cases.
Cost optimizationChoose a more cost-effective model as the fallback to control emergency costs.
Centralized managementConfigure once at the account level and it applies automatically to every request.

Global fallback model configuration

BasicRouter supports setting a global fallback model from the console backend. All requests automatically use this model as a backup when they fail.

How to configure it:

  1. Go to the BasicRouter strategy settings page.
  2. Find the Default Fallback Model setting.
  3. Select your global fallback model from the dropdown list.
  4. Save the setting to apply it immediately.

Advantages of global configuration:

  • No code changes required: configure once and it applies globally, with no need to repeat the setting on every request.
  • Centralized management: manage the fallback policy in one place for easier adjustment and monitoring.
  • Simplified maintenance: reduces code complexity and the chance of configuration errors.
  • Flexible override: request-level fallback configuration takes priority and can override the global setting for specific scenarios.

Request-level fallback configuration

For specific business scenarios, you can specify a fallback model on an individual request to override the global configuration.

Specify the fallback model with the router.fallBackModels parameter:

{
  "model": "claude-sonnet-4",
  "messages": [
    {
      "role": "user",
      "content": "Explain what quantum computing is"
    }
  ],
  "router": {
    "fallBackModels": ["glm-5.2"]
  }
}

Priority rules

When multiple fallback configurations are present, priority runs from highest to lowest:

  1. Request-level router.fallBackModels: the fallback model specified on an individual request.
  2. Global Default Fallback Model: the global fallback model configured in the console.
  3. No fallback: if neither is configured, the request returns an error on failure.
⚠ Important notes
  • If all fallback models fail, the system returns the failure reason from the last model attempted.
  • When a fallback occurs, the response indicates the model actually used, making it easy to monitor and analyze.

Account administration

Depending on account type, the console may include account-level model enablement, reseller or distributor controls, billing configuration, and access settings. Administrators can use these controls to align model access, usage visibility, and billing responsibility with applications, customer accounts, or business units.

Production operations checklist

ItemRecommendation
API keysUse dedicated production keys with clear labels.
ModelsConfirm model availability, pricing, context length, and required capabilities.
RoutingConfigure routing aliases or fallback policies for critical workloads.
LogsEnsure request IDs are captured in application logs.
BillingConfirm wallet balance, plan status, and credit deduction rules.
Rate limitsReview account-level RPM, TPM, concurrency, and media task limits.
AlertsMonitor usage growth, credit balance, errors, and provider availability.

Billing & Credits

BasicRouter uses a credit-based billing model across text, image, video, and other supported model workloads. Credits provide a unified unit for multi-model and multi-provider usage so teams can manage consumption consistently across modalities and API families.

Detailed model pricing is available on the Models page or through model metadata APIs. Pricing may vary by model, provider, modality, resolution, token type, output length, task duration, account type, and commercial agreement.

Top up & wallet

Accounts may add pay-as-you-go wallet credits for flexible usage. Wallet credits are used after monthly plan credits and resource packs have been consumed, unless a custom billing rule applies to the account.

Wallet credits do not expire unless otherwise specified in applicable commercial terms. Service fee is charged when recharging the pay-as-you-go wallet.

Monthly plans and resource packs

Each user or account can select one active monthly plan. Monthly plans provide a defined amount of usage capacity, commercial terms, and account-level access configuration for the billing period.

Users can also buy multiple resource packs for additional usage capacity. Resource packs can separate committed usage from pay-as-you-go wallet balance and are useful for high-volume text, image, video, or dedicated workload usage.

Deduction order

Unless custom billing rules are configured, credits are deducted in the following order:

PriorityCredit sourceDescription
1Monthly planIncluded monthly usage capacity is consumed first.
2Resource packsAdditional purchased packs are consumed after monthly plan credits.
3Pay-as-you-go walletWallet balance is consumed after plan and resource pack credits.

For accounts with custom commercial terms, deduction order, expiration rules, included usage, and pricing may differ. Account-specific rules are shown in the console or provided through the commercial agreement.

Custom pricing

Pricing can be customized for each user or account. Enterprise customers, reseller accounts, distributor accounts, and high-volume customers may be eligible for custom pricing. Contact sales for a quote.

Custom pricing can be configured by account, model, provider, modality, region, usage volume, or commercial agreement. When custom pricing is enabled, the console and billing APIs reflect account-specific pricing and deduction rules where available.

Pricing units

Different model modalities use different measurement units. BasicRouter converts these units into credits according to the model’s pricing rules.

ModalityCommon pricing basis
TextInput tokens, output tokens, cached read tokens, cached write tokens, reasoning tokens, or model-specific token categories.
ImageModel, resolution, number of generated images, input image usage, editing mode, or quality setting.
VideoModel, output resolution, generated seconds, aspect ratio, input image or video usage, and task type.
EmbeddingsInput tokens or number of embedding records.
AudioInput duration, output duration, transcription length, or model-specific audio units.

Pricing units may vary by model. Always refer to the model detail page or pricing metadata before enabling a model in production.

Usage attribution

BasicRouter usage can be reviewed by account, API key, model, modality, or time range. This allows teams to attribute cost to applications, environments, customers, or internal business units.

DimensionDescription
API keyGroup usage by application, service, or environment.
ModelCompare cost and volume by selected model.
Resolved modelReview the actual model used after routing or fallback.
ModalitySeparate text, image, video, embedding, and audio usage.
Time rangeReview daily, monthly, or custom reporting periods.
MetadataGroup usage by custom request metadata such as customer ID, tenant ID, user ID, or environment.

Credit balance

Check how many credits are available across your account. The balance is split into three wallets that are deducted in order: the monthly plan allowance, purchased resource packs, and the pay-as-you-go wallet. A combined resource total (monthly plan + resource packs, excluding pay-as-you-go) is also available for tracking included usage separately from top-up spending.

To retrieve this programmatically, see GET /v1/billing/balance in the API Reference.

Usage details

Review a paginated, chronological list of individual usage records for reporting, monitoring, and internal cost allocation. Each record shows the model, model type (text, image, or video), the credits deducted, and a breakdown of which wallet each deduction was drawn from. Results can be filtered to a specific time range.

To retrieve this programmatically, see GET /v1/usage in the API Reference.

Transaction history

Use transaction history to review credit movements, including top-ups, plan allocations, resource pack grants, usage deductions, adjustments, and administrative corrections.

To retrieve this programmatically, see GET /v1/billing/transactions in the API Reference.

Failed requests and refunds

Validation errors, authentication errors, and permission errors are generally not billed because no model execution occurs. Requests that reach an upstream model or generate partial output may consume credits depending on the model, provider, and response state.

For async image and video tasks, billing behavior depends on whether the task was accepted, started, completed, failed, or cancelled. The task detail response includes usage information when credits have been consumed.

Top-ups, monthly plans, resource packs, and consumed credits are non-refundable unless otherwise specified in the applicable commercial agreement or required by law.

Operational

Errors

BasicRouter returns stable error codes so applications can handle retries, fallbacks, billing issues, and debugging consistently.

Provider-compatible endpoints try to preserve the original API family's error shape where possible. BasicRouter-native endpoints use the BasicRouter error object.

HTTP status and error code mapping

HTTP statusError typeExample codesRetry
400invalid_request_errorinvalid_request, unsupported_parameter, invalid_messages, invalid_image_urlNo
401authentication_errormissing_api_key, invalid_api_keyNo
402billing_errorinsufficient_credits, payment_required, quota_exceededNo
403permission_errormodel_access_denied, endpoint_access_denied, key_scope_deniedNo
404not_found_errormodel_not_found, response_not_found, task_not_foundNo
408timeout_errorgateway_timeout, provider_timeoutYes
409conflict_erroridempotency_conflict, task_already_cancelledDepends
422validation_errorschema_validation_failed, unsupported_modalityNo
429rate_limit_erroraccount_rpm_exceeded, account_tpm_exceeded, provider_rate_limitedYes
500internal_errorinternal_errorYes
502provider_errorprovider_bad_gateway, provider_invalid_responseYes
503service_unavailablemodel_unavailable, provider_unavailable, insufficient_capacityYes
504timeout_errorprovider_timeout, gateway_timeoutYes

Common error codes

CodeMeaningRecommended action
missing_api_keyNo API key was provided.Add the Authorization header.
invalid_api_keyAPI key is invalid or revoked.Create or rotate the API key.
model_not_foundModel ID does not exist or is not enabled for the account.Check the Models page or call GET /v1/models.
model_access_deniedAPI key or account does not have access to the model.Enable the model or contact admin.
unsupported_parameterRequest includes a parameter unsupported by the selected endpoint or model.Remove the parameter or choose a compatible model.
unsupported_modalityInput or output modality is not supported by the selected model.Choose a model that supports the modality.
account_rpm_exceededAccount requests per minute limit exceeded.Retry with backoff or request higher limits.
account_tpm_exceededAccount tokens per minute limit exceeded.Retry with backoff, reduce tokens, or request higher limits.
provider_rate_limitedUpstream provider rate limited the request.Retry or enable fallback.
insufficient_creditsAccount has insufficient credits.Top up wallet, buy a pack, or upgrade plan.
provider_timeoutUpstream provider did not respond in time.Retry or enable fallback.
model_unavailableModel is temporarily unavailable.Retry or use a routing alias.
content_policy_errorRequest or output was blocked by a safety policy.Modify input or choose a suitable workflow.