Claude 5 OpenAI SDK API Guide
The Claude 5 OpenAI SDK API lets a Python application send a standard chat-completions request to https://frugalrelay.me/v1 with a current Claude model name such as claude-sonnet-5. To plan cost, pair the model with the route your account can use, record input and output tokens, and multiply them by that route’s separate rates. In this run’s public catalog, claude-sonnet-5 is available through both the Claude Sale Channel and the Claude Route, which have different prices. Verify the rate you intend to use at Frugal Relay pricing before approving a production budget.
This matters when an application already uses the OpenAI Python SDK but a team wants to evaluate Claude without maintaining another client abstraction for the first test. OpenAI compatibility gives the request a familiar shape; it does not make every model, route, or cost identical. The practical work is to use a canonical model slug, confirm the documented endpoint, test your application’s response handling, and budget the traffic you actually observe.
Claude 5 OpenAI SDK API: make a chat completion
Section titled “Claude 5 OpenAI SDK API: make a chat completion”Catalog fact: The live catalog for this run lists claude-sonnet-5 with both anthropic and openai endpoint types. Its documented OpenAI-compatible endpoint is POST /v1/chat/completions through the base URL https://frugalrelay.me/v1.
Install and configure the OpenAI Python SDK as you normally would, then point its base_url at Frugal Relay. This example uses the canonical live model name and keeps the request deliberately small so it is easy to test from a development shell:
import os
from openai import OpenAI
client = OpenAI( api_key=os.environ["FRUGAL_RELAY_API_KEY"], base_url="https://frugalrelay.me/v1",)
response = client.chat.completions.create( model="claude-sonnet-5", messages=[ { "role": "user", "content": "Summarize this release note in three bullets.", } ],)
print(response.choices[0].message.content)The base URL ends in /v1; the SDK appends the chat-completions path. Keep the API key outside source control, such as in the environment variable shown above or in your deployment platform’s secret store. Getting Started covers the account setup and first authenticated request.
Before treating a successful shell call as an integration result, test the same request shape your service will use. Include the system messages, tool or structured-output handling, timeout settings, streaming behavior, and error parsing that matter to your feature. A compatible request path is useful, but your test suite remains the evidence that your application contract works.
Current Claude 5 route pricing
Section titled “Current Claude 5 route pricing”Catalog fact: The live response lists the following Claude 5 model and route combinations. These are calculated USD prices per 1M tokens using the catalog’s model ratio, completion ratio, and named route ratio. A price applies only to the route printed beside it.
| Model | Claude Sale Channel | Claude Route |
|---|---|---|
claude-sonnet-5 | $0.11 input / $0.55 output | $0.22 input / $1.10 output |
claude-opus-5 | $0.275 input / $1.375 output | $0.55 input / $2.75 output |
claude-fable-5 | Not listed | $1.10 input / $5.50 output |
For example, the $0.11 / $0.55 figures belong only to claude-sonnet-5 on the Claude Sale Channel. They are not a universal Claude 5 price, and the $0.22 / $1.10 figures for the Claude Route are a separate route price for the same model. The catalog determines which routes are eligible; use the route available to your account rather than assuming the lower listed rate applies.
The pricing guide explains the route-specific catalog, while Supported Models lists current model names and endpoint compatibility. Consult both before a deployment, then check the live pricing page again when a budget or rollout decision depends on today’s rate.
How the catalog prices are calculated
Section titled “How the catalog prices are calculated”For token-priced models, the public calculation is:
input USD per 1M tokens = model ratio x 2 x route ratiooutput USD per 1M tokens = input price x completion ratioIn this run, claude-sonnet-5 has a model ratio of 1 and a completion ratio of 5. The Claude Sale Channel’s route ratio is 0.055, so its input rate is 1 x 2 x 0.055 = $0.11 per 1M tokens and its output rate is $0.11 x 5 = $0.55 per 1M tokens. The Claude Route uses a route ratio of 0.11, yielding $0.22 input and $1.10 output per 1M tokens.
This arithmetic is a way to reproduce the live catalog values, not a reason to hard-code a multiplier. Model ratios, completion ratios, route ratios, and eligibility can change. Treat the live page and your account’s available route as the inputs for a fresh estimate.
Estimate a Claude 5 chat request cost
Section titled “Estimate a Claude 5 chat request cost”The useful estimate separates prompt and completion tokens:
estimated cost = (input tokens / 1,000,000 x input route price) + (output tokens / 1,000,000 x output route price)Suppose an observed claude-sonnet-5 request has 125,000 input tokens and 15,000 output tokens on the Claude Sale Channel. With that route’s $0.11 input and $0.55 output price per 1M tokens, the estimate is:
(125,000 / 1,000,000 x $0.11) + (15,000 / 1,000,000 x $0.55)= $0.01375 + $0.00825= $0.022 per requestThe same token profile on the Claude Route uses $0.22 input and $1.10 output per 1M tokens:
(125,000 / 1,000,000 x $0.22) + (15,000 / 1,000,000 x $1.10)= $0.0275 + $0.0165= $0.044 per requestThose totals are route-specific planning calculations, not a billing guarantee. They also cover one completed request, not retries, background evaluations, or other calls your workflow may make. Record the model, named route, input tokens, output tokens, result status, and retry count for each call. Keeping the route in the record prevents a later estimate from silently applying the wrong price to a correct token count.
The AI API cost calculator applies the same formula to request volume and retries.
Production cost optimization for OpenAI-compatible calls
Section titled “Production cost optimization for OpenAI-compatible calls”Recommendation: establish a representative evaluation set before selecting a default model or route. Include short requests, long-context requests, malformed inputs, and cases that commonly lead to a retry. Run the same prompts and application-side validation for each candidate, then compare the results using measurements rather than a token price alone.
A concise comparison record can look like this:
| Measure | Why it belongs in the decision |
|---|---|
| Input and output tokens | Reproduces the route-specific cost calculation |
| Completion or validation result | Shows whether the response completed the task |
| Retry count | Captures extra calls that token-only forecasts miss |
| Application latency | Tests the service behavior your users experience |
| Cost per successful task | Connects price to a validated outcome |
Start with a narrow release slice or internal workflow. Set a maximum request duration, bound retry attempts, and make the action after a failed call explicit: return a handled error, queue work for review, or fall back according to your own product policy. These are implementation recommendations, not claims about model behavior or availability.
Output deserves its own budget because each listed Claude 5 route charges a higher output than input rate. Keep prompts focused on the response your application consumes, validate the response before sending it downstream, and set an output ceiling appropriate to the task and the controls your client and route support. Then measure whether the tighter response contract changes task quality or retry rate. A smaller output is only a win when the feature still succeeds.
Select a model and route with evidence
Section titled “Select a model and route with evidence”The live catalog gives you current names, endpoint types, eligible route groups, and route inputs for pricing. It does not say which Claude 5 model is best for your users. That is an engineering decision based on the task, evaluation results, latency observed by your application, and cost per successful result.
For a fair comparison, hold the prompt, response contract, validation, and traffic sample steady. If claude-sonnet-5, claude-opus-5, and claude-fable-5 are all candidates, run each against the same set and attach the route name to every metric. A model that needs fewer repair calls may be the better production choice even when its listed token rate is higher. Conversely, a lower-priced route can be a sound default only after its measured outcomes meet your feature’s acceptance criteria.
Avoid treating a model change as a pricing-only change. A slug configured in an environment variable, a fallback path, or a job worker can create mixed traffic if it is missed during rollout. Inventory those call sites, use separate development and production credentials, and leave a configuration rollback available until the release data supports expanding traffic.
Production rollout checklist
Section titled “Production rollout checklist”- Set
base_urltohttps://frugalrelay.me/v1and make a controlled chat-completions test call. - Use a canonical current model name, such as
claude-sonnet-5, from Supported Models. - Confirm the model’s eligible route and the named live rate at Frugal Relay pricing.
- Capture input and output tokens, model, route, status, latency, and retry count in your application telemetry.
- Calculate prompt and completion cost with the separate rates for that named route.
- Test normal, long-context, malformed-input, timeout, and validation-failure paths.
- Bound retries and define the caller-visible behavior when a request cannot complete.
- Begin with a small controlled workload and compare observed cost per successful task with the estimate.
Can I call Claude 5 through the OpenAI Python SDK?
Section titled “Can I call Claude 5 through the OpenAI Python SDK?”The live catalog lists claude-sonnet-5 with the OpenAI endpoint type. Point the SDK at https://frugalrelay.me/v1 and use the documented chat-completions request shape shown above. Validate the exact request options your application relies on in a controlled test.
Is the Claude Sale Channel price available to every account?
Section titled “Is the Claude Sale Channel price available to every account?”Do not assume that. The catalog exposes prices by eligible group and route, while actual availability is account-specific. Confirm the route available to your account and use that named route’s price in the estimate.
When should I refresh a cost estimate?
Section titled “When should I refresh a cost estimate?”Refresh it when the model, route, prompt size, output contract, retry policy, or expected traffic changes. Before a material production decision, verify the current rate on Frugal Relay pricing and compare the estimate with measured usage from a controlled release.