@@ -35,6 +35,40 @@ from pydantic_ai import Agent
3535
3636agent = Agent(' gateway/openai:gpt-5' )
3737
38+ result = agent.run_sync(' Where does "hello world" come from?' )
39+ print (result.output)
40+ """
41+ The first known use of "hello, world" was in a 1974 textbook about the C programming language.
42+ """
43+ ```
44+ ``` python {title="passing_api_key.py"}
45+ from pydantic_ai import Agent
46+
47+ from pydantic_ai import Agent
48+ from pydantic_ai.providers.gateway import gateway_provider
49+ from pydantic_ai.models.openai import OpenAIChatModel
50+
51+ provider = gateway_provider(' openai' , api_key = ' PYDANTIC_AI_GATEWAY_API_KEY' )
52+ model = OpenAIChatModel(' gpt-5' , provider = provider)
53+ agent = Agent(model)
54+
55+ result = agent.run_sync(' Where does "hello world" come from?' )
56+ print (result.output)
57+ """
58+ The first known use of "hello, world" was in a 1974 textbook about the C programming language.
59+ """
60+ ```
61+ ``` python {title="routing_via_provider.py"}
62+ from pydantic_ai import Agent
63+
64+ from pydantic_ai import Agent
65+ from pydantic_ai.providers.gateway import gateway_provider
66+ from pydantic_ai.models.openai import OpenAIChatModel
67+
68+ provider = gateway_provider(' openai' , api_key = ' PYDANTIC_AI_GATEWAY_API_KEY' )
69+ model = OpenAIChatModel(' gpt-5' , provider = provider, route = ' modal-ai' )
70+ agent = Agent(model)
71+
3872result = agent.run_sync(' Where does "hello world" come from?' )
3973print (result.output)
4074"""
0 commit comments