How do I list the available models in Python?
GET /v1/models needs no key, but the SDK sends yours anyway, which is fine.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.gateway.clatterlabs.xyz/v1",
api_key=os.environ["CLATTER_API_KEY"],
default_headers={"X-Clatter-Account": os.environ["CLATTER_ACCOUNT_ID"]},
)
for m in client.models.list():
print(m.id, getattr(m, "pricing", None))
The raw response also has families (context window, size, efforts) and retired (Line Code). Use client.models.retrieve("supercosmos-max") for one model.
The client setup above (base URL, key and the X-Clatter-Account header) is the same in every Python example; see Set up the Python SDK. Full parameter list: Create a chat completion.
Good to know#
- Your key's account is responsible for your end users' text under the Abuse policy. What it means for apps
- Model ids:
supercosmos-flash,supercosmos-max,supercosmos-heavy(SuperCosmos 1.1). Which to call - Every response has an
X-Request-Id; log it so a request can be found later. Why log it
Still need help?#
- General support: support@clatterlabs.com or team@clatterlabs.xyz
- Infrastructure questions, or permanent deletion of your data (your whole account or one service): infrastructure@clatterlabs.xyz
We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Related articles
- How do I set up the OpenAI Python SDK for the Model API?
- Can I use OpenAI and the Model API in the same Python program?
- How do I use stop sequences in Python?
- How do I list models in JavaScript?
- What does "list price" mean in Clatter Labs billing?Plans & billing
- Why does GET /v1/models list Line Code under retired?SuperCosmos models
Still need help?
Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyzFor deleting your whole account or the data of one service.