Skip to main content
Some models are sold in a price range: most of their providers charge the base price, and a few charge more. By default, NagaAI sends a request to a dearer provider when the cheaper ones can’t serve it. To make sure a request never costs more than you choose, set a price limit.

Before you begin

Check whether your model has a price range. In GET /v1/models, a row of the model’s pricing that has a max_price next to its price is a range. For example, openai/gpt-6.1-sol costs between 0.0000025 and 0.000005 credits per output token:
A model without max_price costs the same on every provider, so a limit changes nothing for it.

Choose how to limit the price

NagaAI offers two ways to limit the price. Use one of them: A limit removes providers. When none of the model’s providers fits, NagaAI tries your fallback models; without them, the request fails. See Troubleshooting.

Use only base-price providers

  1. Add service_tier: "flex" to a Responses or Chat Completions request.
  2. Send the request:
The response is a normal answer, and output_text holds the model’s text. The request is billed at the base price. Any other service_tier value, or none, lets every provider serve the request.

Set a price cap

  1. In the model’s pricing, find the meter to cap, such as output_token. The routing object lists every meter.
  2. Add routing.max_price with the meter and the most one unit may cost, in credits, as a decimal string.
  3. Send the request:
NagaAI uses only providers that charge at most 0.0000025 credits per output token. The OpenAI Python SDK sends routing through extra_body, because routing is a NagaAI field. A meter the model doesn’t price is skipped, so one cap can serve several models.

Cap the price of an image, video, or audio request

Image, video, speech, transcription, embeddings, moderation, and rerank requests take routing.max_price the same way. Cap the meter that the model’s pricing names, such as output_image_token for an image model:
The response holds the image URL. A video cap on output_video_second is checked against the price of the clip you asked for before anything is spent. Image edits and audio uploads are forms; the OpenAI SDKs send extra_body there as parts such as routing[max_price][input_audio_hour].

Troubleshooting

400: no provider serves this request within its price limit

None of the model’s providers, and none of your fallback models, is within the limit. The message names the model:
Raise routing.max_price to the model’s max_price, drop service_tier: "flex", or add a fallback model in your price.

400: unknown meter

The cap names a meter that NagaAI doesn’t know, such as output_widget. Use a meter from the model’s pricing; The routing object lists every error of routing with its message.

The request cost more than the base price

The model has a range, and the request had no limit. Check that the request sends service_tier: "flex" or routing.max_price. In the OpenAI Python SDK, routing goes in extra_body.

See also

  • The routing object: every field and meter of routing.
  • Routing: how NagaAI orders providers and falls back to other models.
  • Billing: what a request costs and when you’re charged.