Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion clai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-m [MODEL], --model [MODEL]
Model to use, in format "<provider>:<model>" e.g. "openai:gpt-4o" or "anthropic:claude-3-7-sonnet-latest". Defaults to "openai:gpt-4o".
Model to use, in format "<provider>:<model>" e.g. "openai:gpt-4.1" or "anthropic:claude-sonnet-4-0". Defaults to "openai:gpt-4.1".
-a AGENT, --agent AGENT
Custom Agent to use, in format "module:variable", e.g. "mymodule.submodule:my_agent"
-l, --list-models List all available models and exit
Expand Down
8 changes: 4 additions & 4 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ uvx clai --help
You can specify which model to use with the `--model` flag:

```bash
uvx clai --model anthropic:claude-3-7-sonnet-latest
uvx clai --model anthropic:claude-sonnet-4-0
```

(a full list of models available can be printed with `uvx clai --list-models`)
Expand All @@ -72,7 +72,7 @@ You can specify a custom agent using the `--agent` flag with a module path and v
```python {title="custom_agent.py" test="skip"}
from pydantic_ai import Agent

agent = Agent('openai:gpt-4o', instructions='You always respond in Italian.')
agent = Agent('openai:gpt-4.1', instructions='You always respond in Italian.')
```

Then run:
Expand All @@ -92,7 +92,7 @@ Additionally, you can directly launch CLI mode from an `Agent` instance using `A
```python {title="agent_to_cli_sync.py" test="skip" hl_lines=4}
from pydantic_ai import Agent

agent = Agent('openai:gpt-4o', instructions='You always respond in Italian.')
agent = Agent('openai:gpt-4.1', instructions='You always respond in Italian.')
agent.to_cli_sync()
```

Expand All @@ -101,7 +101,7 @@ You can also use the async interface with `Agent.to_cli()`:
```python {title="agent_to_cli.py" test="skip" hl_lines=6}
from pydantic_ai import Agent

agent = Agent('openai:gpt-4o', instructions='You always respond in Italian.')
agent = Agent('openai:gpt-4.1', instructions='You always respond in Italian.')

async def main():
await agent.to_cli()
Expand Down
8 changes: 5 additions & 3 deletions pydantic_ai_slim/pydantic_ai/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def cli_exit(prog_name: str = 'pai'): # pragma: no cover
sys.exit(cli(prog_name=prog_name))


def cli(args_list: Sequence[str] | None = None, *, prog_name: str = 'pai') -> int: # noqa: C901
def cli( # noqa: C901
args_list: Sequence[str] | None = None, *, prog_name: str = 'pai', default_model: str = 'openai:gpt-4.1'
) -> int:
"""Run the CLI and return the exit code for the process."""
parser = argparse.ArgumentParser(
prog=prog_name,
Expand All @@ -120,7 +122,7 @@ def cli(args_list: Sequence[str] | None = None, *, prog_name: str = 'pai') -> in
'-m',
'--model',
nargs='?',
help='Model to use, in format "<provider>:<model>" e.g. "openai:gpt-4o" or "anthropic:claude-3-7-sonnet-latest". Defaults to "openai:gpt-4o".',
help=f'Model to use, in format "<provider>:<model>" e.g. "openai:gpt-4.1" or "anthropic:claude-sonnet-4-0". Defaults to "{default_model}".',
)
# we don't want to autocomplete or list models that don't include the provider,
# e.g. we want to show `openai:gpt-4o` but not `gpt-4o`
Expand Down Expand Up @@ -179,7 +181,7 @@ def cli(args_list: Sequence[str] | None = None, *, prog_name: str = 'pai') -> in
model_arg_set = args.model is not None
if agent.model is None or model_arg_set:
try:
agent.model = infer_model(args.model or 'openai:gpt-4o')
agent.model = infer_model(args.model or default_model)
except UserError as e:
console.print(f'Error initializing [magenta]{args.model}[/magenta]:\n[red]{e}[/red]')
return 1
Expand Down