Skip to content

GitHub Models

Install

To use GitHub Models, you need to either install pydantic-ai, or install pydantic-ai-slim with the openai optional group (as it uses an OpenAI-compatible API):

pip install 'pydantic-ai-slim[openai]'
uv add 'pydantic-ai-slim[openai]'

Configuration

To use GitHub Models, you'll need a GitHub personal access token with the models: read permission.

You can set the GITHUB_API_KEY environment variable and use GitHubProvider by name:

from pydantic_ai import Agent

agent = Agent('github:xai/grok-3-mini')
...

Or initialise the model and provider directly:

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.github import GitHubProvider

model = OpenAIChatModel(
    'xai/grok-3-mini',  # GitHub Models uses prefixed model names
    provider=GitHubProvider(api_key='your-github-token'),
)
agent = Agent(model)
...

GitHub Models supports various model families with different prefixes. You can see the full list on the GitHub Marketplace or the public catalog endpoint.