You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/models.md
+24-5Lines changed: 24 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -611,20 +611,39 @@ Or initialise the model directly with just the model name:
611
611
from pydantic_ai import Agent
612
612
from pydantic_ai.models.cohere import CohereModel
613
613
614
-
model = CohereModel('command', api_key='your-api-key')
614
+
model = CohereModel('command')
615
615
agent = Agent(model)
616
616
...
617
617
```
618
618
619
-
### `api_key` argument
619
+
### `provider` argument
620
620
621
-
If you don't want to or can't set the environment variable, you can pass it at runtime via the [`api_key` argument][pydantic_ai.models.cohere.CohereModel.__init__]:
621
+
You can provide a custom [`Provider`][pydantic_ai.providers.Provider]via the [`provider` argument][pydantic_ai.models.cohere.CohereModel.__init__]:
622
622
623
-
```python {title="cohere_model_api_key.py"}
623
+
```python {title="cohere_model_provider.py"}
624
624
from pydantic_ai import Agent
625
625
from pydantic_ai.models.cohere import CohereModel
626
+
from pydantic_ai.providers.cohere import CohereProvider
626
627
627
-
model = CohereModel('command', api_key='your-api-key')
628
+
model = CohereModel('command', provider=CohereProvider(api_key='your-api-key'))
629
+
agent = Agent(model)
630
+
...
631
+
```
632
+
633
+
You can also customize the `CohereProvider` with a custom `http_client`:
0 commit comments