Jump straight to the numbers

← All articles

A $1 Budget for Python Calls to 2 Models

01 / Set a $1 test budget before writing Python

Calling two AI models should not require two subscriptions or a complicated application. Start with a personal test budget of $1, one short prompt, and two requests. That dollar is a planning target, not a quoted package price, minimum deposit, or guarantee that every model fits your budget.

CheapRelay provides one API key for multiple model providers through an OpenAI-compatible interface. Billing is pay as you go, with no monthly fee or subscription. You pay for actual tokens, including cache reads and writes. Your cost depends on the selected model, its current rates, and the tokens each request uses.

Sign up for CheapRelay, create an API key, and check the current prices before adding funds or making requests. For this exercise, consider Gemini 2.5 Flash and DeepSeek V4 Flash, then confirm their available API identifiers and rates in your account.

02 / Install one Python package and keep the key outside the script

Use a recent Python 3 installation. In your terminal, install the SDK with this command:

python -m pip install openai

Next, set an environment variable containing your key. On macOS or Linux, use the command below with your actual key substituted. Keep it out of shared screenshots and source control.

export CHEAPRELAY_API_KEY='your-key-here'

In Windows PowerShell, use this equivalent:

$env:CHEAPRELAY_API_KEY='your-key-here'

The SDK needs the base URL https://api.cheapapirelay.com/v1 for these requests. Including /v1 selects the OpenAI-compatible routes. You can keep the same client configuration when changing models.

03 / Copy two exact model identifiers before sending requests

A display name and an API identifier are not necessarily identical. Copy each identifier from the current model listing or dashboard. Do not guess the spelling from the names above.

The following script asks you to paste both identifiers when it runs. It then sends the same short prompt to each model. Save the next seven paragraphs as seven separate lines in a file named compare_models.py. The long lines can wrap visually in your editor; keep each as one logical line.

import os

from openai import OpenAI

client = OpenAI(api_key=os.environ['CHEAPRELAY_API_KEY'], base_url='https://api.cheapapirelay.com/v1', max_retries=0, timeout=30.0)

first, second = input('First model ID: ').strip(), input('Second model ID: ').strip()

prompt = 'Give three practical ways to reduce food waste at home. Use fewer than 60 words.'

a = client.chat.completions.create(model=first, messages=[{'role': 'user', 'content': prompt}], max_tokens=120); print(first, a.choices[0].message.content, a.usage, sep='\n')

b = client.chat.completions.create(model=second, messages=[{'role': 'user', 'content': prompt}], max_tokens=120); print(second, b.choices[0].message.content, b.usage, sep='\n')

Run it with python compare_models.py. This uses the Chat Completions interface; check that both selected models support that interface and its max_tokens parameter before running. A request error stops the script, so the second call only happens after the first succeeds.

04 / Read the receipt before increasing the workload

Each request asks for at most 120 output tokens, giving a combined requested output ceiling of 240 tokens. That is not a dollar spending limit. Input tokens also cost money, and model-specific reasoning or cache accounting can affect the bill.

Automatic SDK retries are disabled to make this first experiment easier to inspect. A timeout does not prove that the server stopped processing a request. Check your usage before manually repeating an uncertain call.

  • ■ Read both answers and decide whether either needs a larger output allowance.
  • ■ Inspect the returned usage, then check the account billing record for the actual charge.
  • ■ Subtract that charge from your $1 target before running another experiment.

For rates quoted per million tokens, a basic estimate is input tokens multiplied by the input rate, plus output tokens multiplied by the output rate, divided by 1,000,000. Account for separately priced token categories when applicable. Keep prompts short, change one setting at a time, and use the billing record to decide what you can afford next.

Sign up Try the prices yourself, sign-up credit included.

More reading

DateAisleWritten inTitle
2026-10-29Cheap how-tosEN$1 Debugging Budget: Fix 400 Model Not Found
Trace a 400 model-not-found error with a $1 test budget, exact model IDs, correct API routes, and one small verification request.
2026-10-29Cheap how-tosEN$1 Budget: Build a Beginner Code Explainer
Build a reusable code explainer with a free API client, short prompts, and a $1 spending target. No hosting or subscription required.
2026-10-29Cheap how-tosEN$15 a Month: Move Your Hobby Project Off Free Tiers
A practical 2026 migration plan: budget $15, meter real usage, control retries, and move one service at a time.
2026-10-29Cheap how-tosEN$0.20 to $0.08: Stop Buying the Same AI Answer
Build a small local answer cache, skip repeat API calls, and measure savings without paying for another service.
2026-10-29Cheap how-tosENPay for 2 Examples Before You Pay for 10
A tiny-budget walkthrough for testing zero, one, two and four prompt examples, with token math and a practical stopping rule.
2026-10-28Cheap how-tosEN$1 Budget: One Python Script, Two AI Models
Call two AI models with one key using Python, short prompts, explicit token limits, and a cautious $1 learning budget.