# API services and Coding Plans

Source: https://platform.lyrouter.com/ai_gateway/docs/coding-plan/en
Last updated: 2026-10-22

Many providers offer two kinds of API access: a pay-as-you-go API service billed by token usage, and a Coding Plan, a subscription billed monthly. The two usually differ in address, API key, available models and quota rules, so confirm which one you have before connecting it. In BYOK, choose Token-based for the pay-as-you-go service and Subscription for a Coding Plan. Both are called with the same LYRouter API key, and the platform charges the same service fee for each successful call.

## How the two services differ

The table describes the common case; the provider's own documentation is authoritative:

| Aspect | Pay-as-you-go API | Coding Plan |
| --- | --- | --- |
| Provider billing | By actual token usage | A fixed subscription fee, monthly, quarterly or yearly |
| Quota | Account balance and rate limits | A request or token quota per time window within the plan; once it is used up, the upstream returns 429 |
| Address and key | The API address and API key | Often a separate address, and the key may not work with the API |
| Available models | The provider's API models | The models included in the plan |
| Where it can be used | Any application | Some providers restrict it to coding tools |
| BYOK billing mode | Token-based | Subscription |

## The two billing modes in BYOK

Choose one in Provider & billing, the first step of the BYOK editor:

| | Token-based | Subscription |
| --- | --- | --- |
| Description in the console | "Use list prices published by operations and set a discount per model." | "Record a fixed subscription amount and cycle; tokens are usage-only." |
| Models & cost | Each model shows its list price and you can set a Channel price discount (%); models without a list price cannot be saved | Fill in Subscription amount, Currency, Cycle (Month, Quarter, Year) and Starts at; no model prices are needed |
| Credential limits | Usage and cost limits can be set | Not shown |
| Cost tracking | The provider cost of each call is estimated at list price × discount and counted in BYOK token cost | The subscription amount is converted to a monthly figure and counted in BYOK subscription cost; individual calls carry no cost |
| Platform service fee | Charged for each successful call | Charged for each successful call |

## Check the access address

- **Built-in providers**: after choosing the billing mode, check the Base URL in Current access configuration. The platform maintains this address and you cannot change it; the console notes "Built-in provider URLs follow the selected billing profile; subscriptions fall back to the API URL when needed."
- **When a Coding Plan has its own address**: if Subscription still shows the API address but the provider gives the Coding Plan a separate address, connect it as a Custom provider instead: enter the address from the Coding Plan documentation, choose the matching Interface, choose Subscription as the billing mode, then map upstream models to system models; see [Model mappings and sources](https://platform.lyrouter.com/ai_gateway/docs/mapping/en).
- **Using both**: within a workspace, a built-in provider can have only one BYOK. To use a provider's pay-as-you-go key and Coding Plan key at the same time, connect one through the built-in provider and the other as a custom provider.
- **Test before going live**: before saving, use **Test connection** to confirm that the key matches the address; after saving, send one real call and confirm in the [request logs](https://platform.lyrouter.com/ai_gateway/docs/logs/en) that it succeeded and that Provider has a BYOK tag.

(Screenshot: Provider & billing distinguishes Token-based from Subscription billing and shows the address of the current access configuration.)

## Tips for connecting a Coding Plan

- **Select only the models in the plan**: in Models & cost, clear the models the plan does not cover, so that calls are not rejected upstream for using a model outside the plan.
- **When the quota runs out**: once the plan quota is used up, the upstream returns 429 and the gateway moves to the next credential or channel. If you want a platform source to take over at that point, use Prefer this Channel rather than Only use this BYOK; calls taken over are charged in Credits at platform prices. With Only use this BYOK on, the request ends once every credential fails, and the client receives the 429 returned by the upstream.
- **Several plan accounts**: add keys from several accounts in Credentials; the gateway uses them in priority order.
- **After renewing or upgrading**: edit the BYOK to update Subscription amount and Cycle; after you save, cost tracking uses the new amount.
- **Terms of use**: make sure the provider allows the plan to be used in your scenario, for example through a gateway or in applications other than coding tools.

## Checking costs

- The Subscription amount is converted to a monthly figure: a quarterly amount is divided by 3 and a yearly amount by 12, and the month containing the start date is prorated by the days in effect. The result counts toward BYOK subscription cost in [usage analytics](https://platform.lyrouter.com/ai_gateway/docs/analytics/en), only in the workspace total, and is not allocated to members or API keys.
- Subscription credentials show "Statistics pending" in the cost columns of the BYOK list; token usage is still counted.
- Both billing modes also pay the platform service fee, and when the balance is too low BYOK calls return 402; see [BYOK fees and credentials](https://platform.lyrouter.com/ai_gateway/docs/byok-cost/en).
- The provider's bill is authoritative for what the provider actually charges.

## FAQ

### Test connection shows "Authentication failed" for a key I just copied. Why?

**Answer:** The usual cause is a key that does not match the address, for example a Coding Plan key used with the API address. Check that the Base URL in Current access configuration is the address that belongs to the key; if it is not, connect the key as a custom provider as described above.

### Calls work fine during the day, then start returning 429 after a while. Is LYRouter rate limiting me?

**Answer:** Check the source in Status explanation in the [request logs](https://platform.lyrouter.com/ai_gateway/docs/logs/en). If the source is Upstream, the provider returned the 429, usually because the plan's quota for the current time window is used up; wait for the window to reset or add a key from another account. If the source is Gateway, troubleshoot with [429: rate limits and quotas](https://platform.lyrouter.com/ai_gateway/docs/rate-errors/en).
