$0 Monthly Fee: Set Your Python SDK Base URL
01 / $0 monthly fee does not mean $0 requests
If your budget is tiny, start with one working request, not a chatbot loop. CheapRelay has no monthly fee or subscription: billing is pay-as-you-go, per real token, including cache reads and writes. Your requests still cost money, so the first goal is to verify the connection with minimal input and a short answer.
The critical setting is base_url. For the OpenAI Python SDK, use https://api.cheapapirelay.com/v1. That final /v1 matters. It selects the OpenAI-compatible route family rather than leaving the SDK pointed at the server root.
02 / Use one /v1, not zero or two
The SDK combines its base URL with an endpoint path. For a Chat Completions request, the intended destination is https://api.cheapapirelay.com/v1/chat/completions. You supply the base; the SDK supplies the endpoint.
- ■ Correct base_url: https://api.cheapapirelay.com/v1
- ■ Incomplete for this setup: https://api.cheapapirelay.com
- ■ Too specific: https://api.cheapapirelay.com/v1/chat/completions
- ■ Wrong route family for this walkthrough: https://api.cheapapirelay.com/v1beta
CheapRelay uses /v1beta for Gemini-native routes. This article uses the OpenAI SDK interface, so keep /v1 even when selecting a model from another provider. Route compatibility and model availability are separate checks.
03 / Install the SDK and keep your key outside Python
Install or update the package in your project environment:
python -m pip install --upgrade openai
If you need an account, sign up for CheapRelay, create an API key, and check the current model prices before sending a request. Choose a low-cost model that supports Chat Completions, then copy its exact API model identifier from the current model listing. A display name is not necessarily the identifier accepted by the API.
On macOS or Linux, set these variables in the terminal where you will run Python. Replace both placeholder values:
export CHEAPRELAY_API_KEY='your-relay-key'
export CHEAPRELAY_MODEL='exact-model-id'
In PowerShell, use $env:CHEAPRELAY_API_KEY='your-relay-key' and $env:CHEAPRELAY_MODEL='exact-model-id' instead. Do not commit keys to a repository or paste them into screenshots.
04 / Send one short request with retries disabled
Save the following single-line Python example as test_relay.py. The semicolons separate ordinary Python statements; no additional code block or framework is needed.
import os; from openai import OpenAI; client = OpenAI(api_key=os.environ['CHEAPRELAY_API_KEY'], base_url='https://api.cheapapirelay.com/v1', timeout=20.0, max_retries=0); response = client.chat.completions.create(model=os.environ['CHEAPRELAY_MODEL'], messages=[{'role': 'user', 'content': 'Reply with OK only.'}], max_tokens=64); print(response.choices[0].message.content); print(response.usage)
Run it with python test_relay.py. This requests no more than 64 output tokens using max_tokens, where that parameter is supported. Some models require a different output-limit parameter; check the selected model's compatibility notes if the API rejects it. The limit is a ceiling, not a prediction of actual usage.
The 20-second timeout limits waiting time, not your bill. Disabling SDK retries makes the first test easier to inspect, but it does not guarantee that a timed-out request was never processed. Avoid immediately rerunning an uncertain request several times.
05 / Check the receipt before expanding the prompt
Inspect the returned usage and the relay's billing record. Do not assume a successful response is free or that an output limit caps input charges. Longer prompts and repeated conversation history can increase spending even when answers stay short. Cache reads and writes are also billable.
No fixed per-request estimate belongs here without a selected model and its current rates. Measure one small request first, then decide whether your available balance supports larger tests.
06 / Fix configuration errors before buying more credit
- ■ For authentication errors, check that you supplied the relay key rather than a different provider's key.
- ■ For missing-route errors, inspect base_url for a missing or duplicated /v1.
- ■ For model errors, verify the exact identifier and Chat Completions support.
- ■ For parameter errors, check the model's supported output-limit field.
Change one setting at a time. A correct base URL, one supported model, and one tiny request are enough to establish a useful baseline without turning setup into an expensive experiment.
Sign up Try the prices yourself, sign-up credit included.
More reading
| Date | Aisle | Written in | Title |
|---|---|---|---|
| 2026-10-28 | API pipes and fittings | EN | $0 monthly: Go and Rust API clients A tiny-budget guide to sending OpenAI-compatible requests from Go and Rust without monthly fees or framework overhead. |
| 2026-10-28 | API pipes and fittings | EN | $1 Test Budget: OpenAI Node SDK Through a Relay Connect the OpenAI Node SDK to CheapRelay, make one small request, and estimate token costs before scaling beyond a $1 test budget. |
| 2026-10-28 | API pipes and fittings | EN | $0 in extra software: rotate API keys safely A beginner-friendly API key rotation plan using overlapping credentials, a small test request, and a rollback window—without buying more tools. |
| 2026-10-28 | API pipes and fittings | EN | $1 a day: stay below your API key’s rate limits A tiny-budget walkthrough of per-key request limits, token limits, queues and retries, using a hypothetical $1 daily spending target. |
| 2026-10-28 | API pipes and fittings | EN | $2 Budget: Handle 401, 402 and 429 Without Waste A beginner’s guide to API errors: fix authentication, stop on payment issues, and retry rate limits without exhausting a tiny budget. |
| 2026-10-27 | API pipes and fittings | EN | $1 test budget: Anthropic Messages for OpenAI users Learn Anthropic’s Messages format, translate OpenAI chat requests, and keep your first API experiments within a $1 budget. |