One API across multiple LLM providers: write your code once, switch models by changing a string.
pip install aisuite # base package, no provider SDKs
pip install 'aisuite[anthropic]' # with one provider's SDK
pip install 'aisuite[all]' # with every provider SDKYou need keys only for the providers you call. The provider guides walk through obtaining a key for each one.
Set them as environment variables (tools like python-dotenv or direnv help manage them):
export OPENAI_API_KEY="your-openai-api-key"
export ANTHROPIC_API_KEY="your-anthropic-api-key"Keys can also be passed programmatically to the Client constructor:
client = ai.Client({"openai": {"api_key": "..."}})Model names use the format <provider>:<model-name> — aisuite routes each call to the right provider and translates parameters and responses:
import aisuite as ai
client = ai.Client()
models = ["openai:gpt-4o", "anthropic:claude-3-5-sonnet-20240620"]
messages = [
{"role": "system", "content": "Respond in Pirate English."},
{"role": "user", "content": "Tell me a joke."},
]
for model in models:
response = client.chat.completions.create(
model=model,
messages=messages,
temperature=0.75
)
print(response.choices[0].message.content)Core parameters (temperature, max_tokens, tools, …) work provider-agnostically; aisuite maps them to each SDK's conventions.
Run fully local via Ollama — no API key required:
response = client.chat.completions.create(
model="ollama:llama3.3",
messages=[{"role": "user", "content": "Hello!"}],
)- The list of supported providers lives in
aisuite/providers/(<provider>_provider.py). - Runnable notebooks live in
examples/. - Ready to give the model tools? Continue with the Agents quickstart.