Skip to content

Commit 710b776

Browse files
add Groq client support (#84)
Co-authored-by: Samuel Colvin <[email protected]>
1 parent 75779ee commit 710b776

File tree

13 files changed

+1383
-421
lines changed

13 files changed

+1383
-421
lines changed

docs/api/models/groq.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `pydantic_ai.models.groq`
2+
3+
::: pydantic_ai.models.groq

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PydanticAI is a Python Agent Framework designed to make it less painful to build
1111
## Why use PydanticAI
1212

1313
* Built by the team behind Pydantic (the validation layer of the OpenAI SDK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, Instructor and many more)
14-
* Model-agnostic — currently both OpenAI and Gemini are supported, and Anthropic [is coming soon](https://github.com/pydantic/pydantic-ai/issues/63). And there is a simple interface to implement and customize support for other models.
14+
* Model-agnostic — currently both OpenAI, Gemini, and Groq are supported, Anthropic [is coming soon](https://github.com/pydantic/pydantic-ai/issues/63). And there is a simple interface to implement support for other models.
1515
* Type-safe
1616
* Control flow and composing agents is done with vanilla python, allowing you to make use of the same Python development best practices you'd use in any other (non-AI) project
1717
* [Structured response](results.md#structured-result-validation) validation with Pydantic

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ nav:
3939
- api/models/openai.md
4040
- api/models/gemini.md
4141
- api/models/vertexai.md
42+
- api/models/groq.md
4243
- api/models/test.md
4344
- api/models/function.md
4445

pydantic_ai/models/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@
3030
'openai:o1-preview',
3131
'openai:o1-mini',
3232
'openai:gpt-3.5-turbo',
33+
'groq:llama-3.1-70b-versatile',
34+
'groq:llama3-groq-70b-8192-tool-use-preview',
35+
'groq:llama3-groq-8b-8192-tool-use-preview',
36+
'groq:llama-3.1-70b-specdec',
37+
'groq:llama-3.1-8b-instant',
38+
'groq:llama-3.2-1b-preview',
39+
'groq:llama-3.2-3b-preview',
40+
'groq:llama-3.2-11b-vision-preview',
41+
'groq:llama-3.2-90b-vision-preview',
42+
'groq:llama3-70b-8192',
43+
'groq:llama3-8b-8192',
44+
'groq:mixtral-8x7b-32768',
45+
'groq:gemma2-9b-it',
46+
'groq:gemma-7b-it',
3347
'gemini-1.5-flash',
3448
'gemini-1.5-pro',
3549
'test',
@@ -227,6 +241,10 @@ def infer_model(model: Model | KnownModelName) -> Model:
227241

228242
# noinspection PyTypeChecker
229243
return GeminiModel(model) # pyright: ignore[reportArgumentType]
244+
elif model.startswith('groq:'):
245+
from .groq import GroqModel
246+
247+
return GroqModel(model[5:]) # pyright: ignore[reportArgumentType]
230248
else:
231249
from ..exceptions import UserError
232250

0 commit comments

Comments
 (0)