Integration tutorial
OpenAI Python SDK
Use the official OpenAI client with a custom base URL.
01
Buy or create a key
Use guest checkout or create an account key.
02
Set the base URL
https://discountedtokens.com/v1
03
Send a small test
Verify the route before moving production traffic.
app.py
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DISCOUNTEDTOKENS_API_KEY"],
base_url="https://discountedtokens.com/v1",
)
response = client.chat.completions.create(
model="gpt-5.6",
messages=[{"role": "user", "content": "Reply OK"}],
)
print(response.choices[0].message.content)
Run and verify
python -m pip install openai
export DISCOUNTEDTOKENS_API_KEY="YOUR_DISCOUNTEDTOKENS_KEY"
python app.py
Troubleshooting
- Keep the key in an environment variable.
- Use a model returned by GET /v1/models.
- Handle 401, 402, 429 and 5xx responses explicitly.
Configuration source: official documentation. DiscountedTokens is an independent gateway and is not endorsed by the client vendor.