Skip to content

docs: Add Fireworks.AI and Together.AI examples #1095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions docs/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ from pydantic_ai.providers.openai import OpenAIProvider
model = OpenAIModel(
'anthropic/claude-3.5-sonnet',
provider=OpenAIProvider(
base_url='https://openrouter.ai/api/v1', api_key='your-openrouter-api-key'
base_url='https://openrouter.ai/api/v1',
api_key='your-openrouter-api-key',
),
)
agent = Agent(model)
Expand Down Expand Up @@ -835,7 +836,50 @@ from pydantic_ai.providers.openai import OpenAIProvider
model = OpenAIModel(
'sonar-pro',
provider=OpenAIProvider(
base_url='https://api.perplexity.ai', api_key='your-perplexity-api-key'
base_url='https://api.perplexity.ai',
api_key='your-perplexity-api-key',
),
)
agent = Agent(model)
...
```

### Fireworks AI

Go to [Fireworks.AI](https://fireworks.ai/) and create an API key in your account settings.
Once you have the API key, you can use it with the [`OpenAIProvider`][pydantic_ai.providers.openai.OpenAIProvider]:

```python {title="fireworks_model_init.py"}
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel
from pydantic_ai.providers.openai import OpenAIProvider

model = OpenAIModel(
'accounts/fireworks/models/qwq-32b', # model library available at https://fireworks.ai/models
provider=OpenAIProvider(
base_url='https://api.fireworks.ai/inference/v1',
api_key='your-fireworks-api-key',
),
)
agent = Agent(model)
...
```

### Together AI

Go to [Together.ai](https://www.together.ai/) and create an API key in your account settings.
Once you have the API key, you can use it with the [`OpenAIProvider`][pydantic_ai.providers.openai.OpenAIProvider]:

```python {title="together_model_init.py"}
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel
from pydantic_ai.providers.openai import OpenAIProvider

model = OpenAIModel(
'meta-llama/Llama-3.3-70B-Instruct-Turbo-Free', # model library available at https://www.together.ai/models
provider=OpenAIProvider(
base_url='https://api.together.xyz/v1',
api_key='your-together-api-key',
),
)
agent = Agent(model)
Expand Down