cheapaimodel

OpenAI SDK

Use the official OpenAI Python and TypeScript SDKs with cheapaimodel.

Copy

Point the SDK at our base URL and pass your cheapaimodel key. Everything else stays the same.

Terminal
pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.cheapaimodel.ai/v1",
    api_key=os.environ["CHEAPAIMODEL_API_KEY"],
)

# Chat Completions
completion = client.chat.completions.create(
    model="deepseek-v4-1-flash",
    messages=[{"role": "user", "content": "Explain recursion in one sentence."}],
)
print(completion.choices[0].message.content)

# Responses
response = client.responses.create(
    model="deepseek-v4-1-flash",
    input="Explain recursion in one sentence.",
)
print(response.output_text)

Environment variables

The SDKs also read OPENAI_BASE_URL and OPENAI_API_KEY, which is handy for tools built on them:

Terminal
export OPENAI_BASE_URL="https://api.cheapaimodel.ai/v1"
export OPENAI_API_KEY="$CHEAPAIMODEL_API_KEY"

Swap deepseek-v4-1-flash for any model in the catalog that lists these endpoints.

Copy
Open in

On this page