OpenAI SDK
Use the official OpenAI Python and TypeScript SDKs with cheapaimodel.
Point the SDK at our base URL and pass your cheapaimodel key. Everything else stays the same.
pip install openaiimport 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:
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.