Skip to content

Commit 9ffb65d

Browse files
committed
add troubleshooting docs
1 parent 4537c07 commit 9ffb65d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/troubleshooting.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Troubleshooting
2+
3+
Below are suggestions on how to fix some common errors you might encounter while using PydanticAI. If the issue you're experiencing is not listed below or addressed in the documentation, please feel free to make a post in the Pydantic Slack or on the PydanticAI GitHub Issues page (visit [Getting Help](help.md) for more details).
4+
5+
Some common errors addressed on this page:
6+
7+
1. [Jupyter Notebook Errors](#jupyter-notebook-errors)
8+
2. [API Key Configuration](#api-key-configuration)
9+
10+
## Jupyter Notebook Errors
11+
12+
### `RuntimeError: This event loop is already running`
13+
14+
This error is caused by conflicts between the event loops in Jupyter notebook and `pydantic-ai`'s agent. One way to manage these conflicts is by using [`nest-asyncio`](https://pypi.org/project/nest-asyncio/). Namely, before you execute any agent runs, do the following:
15+
```python {test="skip" lint="skip"}
16+
import nest_asyncio
17+
18+
nest_asyncio.apply()
19+
```
20+
Note: This fix also applies to Google Colab.
21+
22+
23+
## API Key Configuration
24+
25+
### `UserError: API key must be provided or set in the [MODEL]_API_KEY environment variable`
26+
27+
If you're running into issues with setting the API key for your model, visit the [Models](models.md) page to learn more about how to set an environment variable and/or pass in an `api_key` argument.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ nav:
2424
- testing-evals.md
2525
- logfire.md
2626
- multi-agent-applications.md
27+
- troubleshooting.md
2728
- Examples:
2829
- examples/index.md
2930
- examples/pydantic-model.md

0 commit comments

Comments
 (0)