Skip to content

ai& SDK

The official ai& SDKs are generated from the public OpenAPI spec and ship full type definitions. They cover the same OpenAI-compatible surface as the rest of the platform.

Terminal window
pip install aiand
import aiand
configuration = aiand.Configuration(access_token="sk-your-aiand-api-key")
client = aiand.OpenaiApi(aiand.ApiClient(configuration))
models = client.list_models()
print(models.data[0].id)
response = client.create_chat_completion(
aiand.CreateChatCompletionRequest.from_dict({
"model": "google/gemma-4-31b-it",
"messages": [{"role": "user", "content": "Hello"}],
})
)
print(response.choices[0].message.content)
response = client.create_response(
aiand.CreateResponseRequest(
model="google/gemma-4-31b-it",
input=aiand.ResponseInput("Hello"),
)
)
# output[0] is often a reasoning item
message = next((item for item in response.to_dict()["output"] if item["type"] == "message"), None)
if message:
print(message["content"][0]["text"])
else:
print(f"No message in the output (status: {response.status})")
  • list_models() / listModels() — Models
  • Files, uploads, and more follow the same client — see Files