Quickstart
Get up and running with AISuite in under 5 minutes. Learn how to install, configure, and make your first API call.
1. Installation
Install command:
pip install aisuite
You can also install with specific providers:
# Install with specific providers
pip install 'aisuite[anthropic]'
pip install 'aisuite[openai,anthropic]'
pip install 'aisuite[all]' # Install all providers
2. Basic Usage
Initialize the client and make your first request:
example.py
import aisuite as ai
# Initialize client with provider configurations
client = ai.Client({
"openai": {"api_key": "your-openai-key"},
"anthropic": {"api_key": "your-anthropic-key"}
})
# Make a request to any provider
response = client.chat.completions.create(
model="openai:gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me a joke"}
]
)
print(response.choices[0].message.content)
3. Configuration Options
Using Environment Variables
The recommended way to manage API keys is through environment variables:
Environment variables
import aisuite as ai
import os
# Set API keys as environment variables
os.environ['OPENAI_API_KEY'] = 'your-openai-key'
os.environ['ANTHROPIC_API_KEY'] = 'your-anthropic-key'
# Client will automatically use environment variables
client = ai.Client()
# The provider will use the environment variable
response = client.chat.completions.create(
model="anthropic:claude-3-5-sonnet-20240620",
messages=[{"role": "user", "content": "Hello!"}]
)
4. Using Multiple Providers
One of AISuite's key features is the ability to use the same code with different providers:
Multi-provider example
import aisuite as ai
client = ai.Client()
models = ["openai:gpt-4o", "anthropic:claude-3", "google:gemini-pro"]
for model in models:
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "What is 2+2?"}],
temperature=0.7
)
print(f"{model}: {response.choices[0].message.content}")
5. Model Format
AISuite uses a simple format for specifying models: provider:model
Provider | Example Models |
---|---|
OpenAI | openai:gpt-4o, openai:gpt-3.5-turbo |
Anthropic | anthropic:claude-3-5-sonnet-20240620 |
google:gemini-pro, google:gemini-pro-vision | |
Mistral | mistral:mistral-large-latest |
Groq | groq:llama3-8b-8192 |