EN ▾
Get API key

Cheaper Alternative to OpenAI: Switch by Base URL

A cheaper alternative to openai for text is usually a base URL change away: swap the URL, key and model ID, and your OpenAI SDK code keeps working. Here is the exact code, what differs, and how to compute your savings.

Updated

A cable being moved to a neighboring glowing socket, representing a base URL switch to a cheaper API

Cheap AI APIs

Key points

  1. Change base URL to https://api.cheapaiapis.com/v1, key, and model ID to uncensored.
  2. Text only: no images, audio, video, embeddings or fine-tuning.
  3. Rates are $0.15 per 1M input and $0.50 per 1M output tokens, prepaid.
  4. Keep settings in environment variables so you can switch back.

What you change and what you do not

If you want a cheaper alternative to openai for text generation, the migration is small: a new base URL, a new key and a new model ID. Your prompts, message format, streaming code and tool definitions keep their shape. That is the benefit of an OpenAI-compatible API, and it is also the reason you can test the move in an afternoon without a rewrite.

What you cannot move is anything outside text chat. This endpoint offers chat completions, the responses method and a models list. It does not do images, audio, video, embeddings or fine-tuning. If your product uses those, keep that part where it is and move only the text calls.

SettingValue for this service
Base URLhttps://api.cheapaiapis.com/v1
Model IDuncensored
AuthAuthorization: Bearer YOUR_KEY
MethodsPOST /v1/chat/completions, POST /v1/responses, GET /v1/models

Switch in Python, Node or curl

In Python, pass the new values when you create the client:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.cheapaiapis.com/v1",
    api_key="YOUR_KEY",
)

r = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "Answer in two sentences."},
        {"role": "user", "content": "Why do retries need jitter?"},
    ],
)
print(r.choices[0].message.content)

In Node:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.cheapaiapis.com/v1",
  apiKey: process.env.CHEAP_KEY,
});

const r = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Why do retries need jitter?" }],
});
console.log(r.choices[0].message.content);

And plain HTTP:

curl https://api.cheapaiapis.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"user","content":"Why do retries need jitter?"}]}'

Make the switch reversible

Do not hard-code the new values. Put the three settings in environment variables or a config object, and you can flip back in seconds if the new model does not suit one of your features.

import os
from openai import OpenAI

client = OpenAI(
    base_url=os.environ.get("LLM_BASE_URL", "https://api.cheapaiapis.com/v1"),
    api_key=os.environ["LLM_API_KEY"],
)
MODEL = os.environ.get("LLM_MODEL", "uncensored")

A good rollout sends a small share of traffic to the new endpoint first, for example one internal tool or 5% of requests, and compares outputs. Keep the old route as the fallback for 429 or 5xx errors. When you read the response, treat only the standard fields as stable: choices[0].message.content, usage and finish_reason.

What actually differs

  • The model. There is one open-weight model, run by an independent provider, tuned to answer without content refusals for lawful adult use. It is not the official API of any vendor, not a router, and it will not behave exactly like the model you leave. Prompts tuned for another model may need small edits.
  • Context. The window is 100,000 tokens, counting prompt plus completion. max_tokens is optional.
  • Features. Streaming over SSE, tool calling, JSON mode, and pass-through of temperature, top_p, stop, seed and the penalties are supported. Check the docs for anything exotic that your code uses.
  • Limits. A full key allows 8 concurrent requests and 300 per minute. The maximum body is 8 MB.
  • Safety. Content refusals are not the default behavior, but sexual content involving minors is never allowed. Add your own filters if your product has its own rules.

Test tool calling and JSON mode specifically, since a different model may format arguments differently. Validate the JSON you get back, and retry once with a stricter instruction if parsing fails.

A migration checklist that fits in an afternoon

  1. List your calls. Search the code for every place that creates a client or calls the API. Mark each as text chat or something else.
  2. Collect 30 real prompts from logs, with private details removed, including a few long ones, a few that use tools and a few that expect JSON.
  3. Replay them against both endpoints and save the outputs side by side. Count how many are acceptable without edits.
  4. Check streaming. Set stream: true and make sure your UI handles the final usage chunk.
  5. Check errors. Force a bad key and a burst of requests, and confirm your code handles 401 and 429 sensibly.
  6. Roll out slowly, with the old route kept as a fallback.
stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Explain idempotency keys briefly."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Remember that a streamed request holds its concurrency slot until the stream ends. If a page opens several streams at once, a full key's 8 slots can fill up before the 300 per minute does. A 429 with code concurrency tells you that is what happened.

Work out the savings with your own numbers

Rates here are $0.15 per 1M input tokens and $0.50 per 1M output tokens, prepaid and with no subscription. We do not state anyone else's prices; look at the current pricing of the service you use now. Then run this:

def monthly_cost(requests, in_tokens, out_tokens, in_rate, out_rate):
    return requests * (in_tokens * in_rate + out_tokens * out_rate) / 1_000_000

# here: 0.15 per 1M input, 0.50 per 1M output
mine = monthly_cost(30_000, 2_500, 600, 0.15, 0.50)
print(round(mine, 2))   # 20.25

Check that figure by hand: each request costs 2,500 x 0.15 / 1M = $0.000375 for input plus 600 x 0.50 / 1M = $0.0003 for output, so $0.000675. Multiplied by 30,000 requests, it is $20.25. Run the same function with your current provider's published rates and compare. Include the cost of any rewrites or retries in the comparison, not only per-token prices.

Failed or refused requests are not charged, and credit never expires, so a slow month costs nothing extra.

Start with the trial

Sign up with Google, or with an email and password, then claim the $0.50 trial credit with one click on the API key page. It needs no card, lasts 7 days and is limited to one per person. At the example cost above, $0.50 pays for about 740 requests of that size, which is enough to run your own regression prompts against both providers and compare.

When you are ready to pay, top-ups are any whole amount from $20 to $500, with +5% from $50, +10% from $100 and +15% from $200. You can use crypto (USDT on TRC20, USDC on Base). The pricing page shows the current table. Prompts are not used for training.

When to stay where you are

Honest advice: do not switch if your product depends on image, audio or embedding endpoints from your current provider, if you need a specific vendor's model for contractual reasons, or if your users expect that vendor's exact behavior. A cheaper route also does not help if the engineering time to adapt your prompts exceeds the savings. Use this service for the text calls where an uncensored, pay-per-token model fits, and keep the rest where it is.

For an overview of the common myths about low-cost APIs, read cheap GPT API myths versus facts before you decide.

Questions and answers

Read the docs
Do I have to rewrite my code?

Usually not. Chat completions, streaming, tool calling and JSON mode keep the same format. Change the base URL, key and model name.

Can I use embeddings or image generation here?

No. The service is text only, with no image, audio or video generation, no embeddings and no fine-tuning.

Will answers match my current model?

No. It is a different open-weight model tuned to answer without content refusals for lawful adult use, so test your prompts and adjust.

How do I compare costs?

Multiply your monthly input and output tokens by $0.15 and $0.50 per 1M, then compare with your current provider's published rates.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key

https://api.cheapaiapis.com/v1