MEGARIDER

Build with MegaRider.

One API key, one endpoint, every available model.

Quickstart

  1. Request a MegaRider API key.
  2. Set the base URL to https://api.megarider.pro/v1.
  3. Choose an exact model ID from GET /v1/models.
  4. Send messages to POST /v1/chat/completions.

All requests use your MegaRider key. No separate provider credentials or sign-in flow is required.

curl https://api.megarider.pro/v1/models -H "Authorization: Bearer $MEGARIDER_API_KEY"

Chat completions

The request and response format is the same across models. Replace the model ID below with one returned by your catalog.

curl https://api.megarider.pro/v1/chat/completions -H "Authorization: Bearer $MEGARIDER_API_KEY" -H "Content-Type: application/json" -d '{"model":"openai/gpt-5.5","messages":[{"role":"user","content":"Reply with OK."}],"max_tokens":1024}'

Read the answer from choices[0].message.content. Actual token usage is returned in usage when available. Model IDs identify models in MegaRider; they do not change the base URL or authentication.

Streaming

Add "stream": true and use curl -N. Read data: events and collect choices[0].delta.content until [DONE]. Reasoning, when available, is returned separately in reasoning_content. Usage may arrive in a final event with an empty choices array. Heartbeat comments may appear between events.

An error event or a stream ending without [DONE] means the response is incomplete.

Parameters

FieldBehavior
modelRequired. Exact ID from your authenticated catalog.
messagesRequired. Non-empty array of text messages with role and content.
streamOptional boolean; defaults to false.
max_tokensOptional output preference. Defaults to 1,024 for models with adjustable output. Finite numeric values are rounded down and clamped to 1 through the lower model or key limit. Oversized values do not cause a range error.
max_completion_tokensAlias for max_tokens. Supply only one of these fields.
tools / tool_choiceFunction definitions and tool selection. Your application executes returned tool calls.

For models with supports_max_tokens=false, MegaRider accepts the same request fields but manages output automatically; the requested cap is not enforced. The catalog reports reservation_output_tokens, the output allowance required for quota checks. This allowance is not a token charge. Keep sufficient key output allowance, TPM and remaining quota for the selected model.

Text input and one completion per request are supported. Images, audio, batch jobs, log probabilities and guaranteed structured JSON output are not currently offered.

Model preferences

All connections accept the same request format. Sampling and reasoning fields are preferences: unsupported fields use the model default and are listed in the response header X-MegaRider-Ignored-Parameters. This applies to temperature, top_p, stop, seed, frequency_penalty, presence_penalty and reasoning_effort. Some models accept a narrower temperature range, which MegaRider clamps. When only one sampling control is supported, temperature takes priority over top_p. In particular, a stop sequence listed in this header is not enforced.

Response format

Every JSON completion contains id, object: "chat.completion", created, model, choices and usage. Each choice has index 0, an assistant message and finish_reason (stop, length, tool_calls or content_filter). Optional reasoning, refusal and function calls remain in the message. Usage contains prompt_tokens, completion_tokens and total_tokens plus cache/reasoning details; it is null when no complete usage report is available.

Streaming uses the same identity for every event, object: "chat.completion.chunk", and choices[0].delta for incremental content and tool arguments. A final usage event has an empty choices array. Provider-specific envelopes are not exposed.

Model catalog

GET /v1/models returns models currently available to your key. Availability depends on permissions and capacity and may change. Prices come from the published OpenRouter model catalog and refresh hourly. A model without a matching valid price cannot accept new requests until its price is available; it is never treated as free.

Download the OpenAPI specification. Compatible chat-completions clients can use the MegaRider base URL and key.

Pricing and token accounting

MegaRider calculates USD costs using the OpenRouter model catalog, including MiniMax and all connected models. The price is fixed at request start. Model metadata in /v1/models includes the OpenRouter model ID, rates per million tokens, cache rates, long-context tiers and the price timestamp. These are MegaRider accounting amounts based on reference prices, not an OpenRouter invoice.

Actual reported input and output tokens determine the charge. Reported cache reads and writes use the corresponding catalog rates. Reasoning tokens are already included in output tokens and are not charged twice. Long-context tiers apply when the reported prompt reaches their threshold. When usage is complete, usage.cost contains the computed USD amount and usage.cost_details identifies the price source and version, in both JSON and the final streaming usage event. Unknown usage remains unresolved. Amounts are rounded once per request to the nearest billionth of a dollar.

Valid cached prices keep service available during temporary catalog failures for up to seven days. Missing or older prices block new generation requests until refreshed. Existing historical charges retain their original rates.

Limits and errors

Limits are configured per key: requests and tokens per minute, concurrency, output allowance, lifetime token quota, spend ceiling and expiration. Request bodies are limited to 1 MiB and the request deadline is 120 seconds. These limits do not guarantee throughput.

Before dispatch, MegaRider reserves an input estimate plus output allowance. Reported usage replaces the reservation, releasing unused capacity. If usage is unknown after interruption, reserved capacity stays held pending reconciliation. A quota error can require a smaller request or a key limit change. Automatic output models may still require a larger allowance even when a small max_tokens value is supplied.

StatusAction
400 / 413 / 415Check the request fields, content type, payload size or required model allowance.
401Check your MegaRider bearer key.
429Respect Retry-After for temporary limits. For exhausted quotas, reduce the request or adjust key limits.
502 / 503 / 504Generation failed, capacity is unavailable or the deadline expired. Retrying can incur additional usage.

MegaRider routes requests to available capacity. A request rejected before generation may use another eligible connection; accepted or uncertain generations are not replayed automatically.

Message content

Message content accepts a string or an array of text blocks, for example [{"type":"text","text":"Hello"}]. Blocks are joined in order without added separators. Images, audio and files are not supported.

Timeouts and interrupted streams

The server request deadline is 300 seconds. An accepted event stream may be closed after 120 seconds without upstream activity. Set client timeouts accordingly. Error codes distinguish request_deadline, upstream_idle_timeout and client_disconnected. Client disconnects are recorded as 499 in diagnostics. Confirmed token usage remains chargeable when delivery is interrupted; unknown usage requires reconciliation. Do not automatically retry an accepted generation.

Compatibility and capacity

Structured outputs are disabled: JSON mode and JSON schema requests return 400. Current gateway capacity is 4 concurrent requests, with 2 per model; key-specific limits also apply. Capacity and rate failures return 429 with type: rate_limit_error, code: rate_limit_exceeded and Retry-After. Clients should honor that delay; accepted generations are not automatically retried.

Public /v1 API routes support unauthenticated CORS OPTIONS for bearer-token browser clients. Admin cookie endpoints do not use this CORS policy. Unknown API paths return JSON 404 errors.

With stream_options: {include_usage: true}, streaming usage is included exactly once in a final JSON chunk with choices: [], before [DONE], when the provider reports valid usage. By default, or with include_usage: false, usage is omitted from the stream. Other chunks contain usage: null when usage is requested. Accounting stays enabled. Interrupted streams may end without final usage or [DONE].

Optional null parameters use their defaults. The legacy reasoning_split preference is ignored and reported in X-MegaRider-Ignored-Parameters; reasoning stays separate from answer text. Stream obfuscation is not supported.

Requests may wait up to 15 seconds for a model slot, without reserving billable quota. Non-streaming requests and upstream acceptance have a 300-second deadline. Accepted streams may run for up to 30 minutes, with a 120-second upstream event idle timeout. Client cancellation stops the upstream request.

Support

Contact hello@megarider.pro with the X-Request-Id response header, UTC time and error code. Never include your API key or sensitive prompt content. See the terms and privacy notice for service and data-handling details.