Why an HTTP 402 appears on a pay-per-token API relay
An HTTP 402 response is the HTTP status code for Payment Required. On a pay-per-token API relay such as SwiftRelay, it points to a straightforward issue: the request reached the relay, but the account attached to the request did not have enough available credit to cover the call.
That makes the status code useful rather than mysterious. It tells you to look at your SwiftRelay balance and the key you are sending, not to rewrite your prompt or wait for a timeout. SwiftRelay has no monthly fee and nothing to subscribe to. You top up a balance, and each call deducts only what it used, so the balance is the fuel tank for your requests.
Think of the first run of a new system. The engine is ready, the route is set, and the dashboard shows the trip is funded. If the tank is empty, a 402 is the relay telling you before the journey that more credit is needed. Once you top up, the same request can proceed without changing your application logic.
SwiftRelay also gives new accounts $0.22 in sign-up gift credit. That is enough to make an initial test, but it is not a substitute for planning around the cost of a working session. For advanced use, the goal is not merely to silence a 402; it is to understand exactly which balance, key and model are involved.
Check the balance and the key that owns the request
Start with the two things that control whether a SwiftRelay request can be paid for: the account balance and the API key. Open the dashboard and review the credit available on the account. If the balance is at or near zero, top up before your next run. SwiftRelay offers top-up amounts of $1.39, $6.94, $13.89, $27.78, $69.44 and $138.89.
Then confirm that the request is using the right swft_ key. A stale key, a key copied with extra spaces, or a key from an environment variable that was never exported can all send you down the wrong path. The configuration is designed to be short: copy three lines, paste them into your shell and run.
For Claude Code, the lines are:
01 export ANTHROPIC_BASE_URL=https://api.fastapirelay.com 02 export ANTHROPIC_AUTH_TOKEN=<your swft_ key>
claude
For Codex, the lines are:
01 export OPENAI_BASE_URL=https://api.fastapirelay.com/v1 02 export OPENAI_API_KEY=<your swft_ key>
codex
For Gemini CLI, the lines are:
01 export GOOGLE_GEMINI_BASE_URL=https://api.fastapirelay.com 02 export GEMINI_API_KEY=<your swft_ key>
gemini
For OpenAI-compatible clients, use the base URL https://api.fastapirelay.com/v1 with a swft_ key as the API key. Claude models answer only through the official Claude Code or Claude Desktop client, version 2.1.285 or later. Gemini models use only their native protocol through Gemini CLI.
One advanced habit is to export the variables in the same terminal session where you launch the client. A configuration that works in one window can be invisible in another. If a request suddenly returns 402 after working earlier, check the active environment before changing anything else.
Match the client, protocol and model before you top up again
A 402 can prompt unnecessary top-ups when the real problem is a mismatched setup. Before adding credit, verify that the client, protocol and model belong together. Claude models belong with the official Claude Code or Claude Desktop client. Gemini belongs with Gemini CLI through its native protocol. Codex, Cursor, Cline, Roo Code, Cherry Studio, OpenCode, SDKs and cURL use the OpenAI-compatible endpoint, and that endpoint pairs with GPT, DeepSeek and the other remaining models, never with Claude or Gemini.
That separation matters because an HTTP 402 is a payment signal, but a clean run also depends on sending the request in the format the model expects. Think of it as a pit stop checklist: check the fuel, check the key, check the tyre compound. Each check is quick, and together they keep you from changing the wrong component.
You can also manage up to 20 live API keys per account. More keys are useful when you separate projects, teams or experiments, but they also make key discipline more important. Label each key by purpose, remove keys you no longer need, and confirm that the environment you are testing points to the key you think it does.
If you are comparing options, keep the billing model in view. SwiftRelay charges per token, with no monthly fee and no subscription. That can suit a developer who wants to pay for what a relay actually uses rather than keep a separate subscription or official account running for occasional work. The balance then becomes a visible ledger for your API activity.
Read the token and cost data behind every call
Fixing a 402 is only the first lap. The next step is to understand the usage that consumed the balance. SwiftRelay lists tokens and cost per call, so you can connect each request to the amount it used instead of guessing from a monthly total.
Current prices per 1M tokens on the SwiftRelay pricing page show a wide spread between models. Claude Fable 5.1 is listed at $3.44 for input, $17.18 for output and $0.2222 for cache read. Claude Haiku 4.5 is listed at $0.3542 input, $1.69 output and $0.0278 cache read. Claude Opus 5.5 is listed at $1.53 input, $7.27 output and $0.0694 cache read.
Other choices sit elsewhere on the same per-token scale. Claude Sonnet 5 is $1.01 input, $5.06 output and $0.0889 cache read. Claude Sonnet 5.5 is $0.9792 input, $4.89 output and $0.0861 cache read. DeepSeek V4 Flash is $0.2639 input, $1.06 output and $0.006944 cache read. Gemini 3.1 Pro is $1.35 input, $7.81 output and $0.1347 cache read. GPT-6.1 Sol is $0.1736 input, $0.8542 output and $0.0347 cache read.
Example: if one call uses 1M input tokens and 1M output tokens, the listed prices add up to $21.62 for Claude Fable 5.1, $2.0442 for Claude Haiku 4.5, $8.80 for Claude Opus 5.5, $1.9892 for Claude Sonnet 5.5, $1.3239 for DeepSeek V4 Flash, $9.16 for Gemini 3.1 Pro and $1.0278 for GPT-6.1 Sol. These are examples based on the listed per-1M-token prices, not quotes for a particular prompt.
Use that visibility to pick a model that fits the job, then watch the usage list again. A workflow that burns credit quickly may need a different model or a smaller context. A relay is easy to value when you can see what each call costs.
Build a credit plan that includes refunds and rewards
An advanced setup treats the balance as a managed resource. Choose a top-up amount that matches how often you expect to work, then use the usage list to adjust it. There is no need to buy a plan in advance; you simply add credit when the account needs it, and every call deducts only what it used.
SwiftRelay also provides a refund for unused credit within 11 days of a top-up, minus what was used and the payment fee. That window is worth remembering when you are testing a new project. Keep your top-ups aligned with your actual working period rather than loading everything at once.
Referrals add another route to extending the balance. You receive 14% of each top-up by someone you invited, and 3% from the people they invite. Rewards can be withdrawn once you reach the $4.86 minimum, or they can be moved into the balance.
Example: if an invited teammate tops up $27.78, the 14% referral reward is $3.8892. If that teammate then invites another person who tops up $27.78, the 3% reward is $0.8334. These are examples calculated from the stated referral percentages.
Need help with a balance, a key or a setup question? SwiftRelay support is available through Messages in the dashboard, where you need to be logged in. There is no support email, so keep your questions and screenshots in one place inside the dashboard for a cleaner back-and-forth.
Run the pit-stop routine and keep your relay funded
HTTP 402 is a signal to check the balance, confirm the swft_ key, verify the client and model pairing, and then top up if needed. SwiftRelay keeps the rest simple with pay-per-token billing, no monthly fee, usage details for tokens and cost per call, and setup that takes three copied lines.
Sign up for SwiftRelay today, claim your $0.22 in sign-up gift credit, top up your balance and get your next API run back on track in a clean first lap.