You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/agents.md
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ The most common properties of an agent you'll configure are:
9
9
-`name`: A required string that identifies your agent.
10
10
-`instructions`: also known as a developer message or system prompt.
11
11
-`model`: which LLM to use, and optional `model_settings` to configure model tuning parameters like temperature, top_p, etc.
12
+
-`prompt`: Reference a prompt template by id (and variables) when using OpenAI's Responses API.
12
13
-`tools`: Tools that the agent can use to achieve its tasks.
13
14
-`mcp_servers`: MCP servers that provide tools to the agent. See the [MCP guide](mcp.md).
14
15
-`reset_tool_choice`: Whether to reset `tool_choice` after a tool call (default: `True`) to avoid tool-use loops. See [Forcing tool use](#forcing-tool-use).
@@ -29,6 +30,65 @@ agent = Agent(
29
30
)
30
31
```
31
32
33
+
## Prompt templates
34
+
35
+
You can reference a prompt template created in the OpenAI platform by setting `prompt`. This works with OpenAI models using the Responses API.
36
+
37
+
To use it, please:
38
+
39
+
1. Go to https://platform.openai.com/playground/prompts
40
+
2. Create a new prompt variable, `poem_style`.
41
+
3. Create a system prompt with the content:
42
+
43
+
```
44
+
Write a poem in {{poem_style}}
45
+
```
46
+
47
+
4. Run the example with the `--prompt-id` flag.
48
+
49
+
```python
50
+
from agents import Agent
51
+
52
+
agent = Agent(
53
+
name="Prompted assistant",
54
+
prompt={
55
+
"id": "pmpt_123",
56
+
"version": "1",
57
+
"variables": {"poem_style": "haiku"},
58
+
},
59
+
)
60
+
```
61
+
62
+
You can also generate the prompt dynamically at run time:
63
+
64
+
```python
65
+
from dataclasses import dataclass
66
+
67
+
from agents import Agent, GenerateDynamicPromptData, Runner
Agents are generic on their `context` type. Context is a dependency-injection tool: it's an object you create and pass to `Runner.run()`, that is passed to every agent, tool, handoff etc, and it serves as a grab bag of dependencies and state for the agent run. You can provide any Python object as the context.
Copy file name to clipboardExpand all lines: docs/config.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,13 @@ from agents import set_tracing_export_api_key
38
38
set_tracing_export_api_key("sk-...")
39
39
```
40
40
41
+
If you need to attribute traces to a specific organization or project when using the default exporter, set these environment variables before your app starts:
42
+
43
+
```bash
44
+
export OPENAI_ORG_ID="org_..."
45
+
export OPENAI_PROJECT_ID="proj_..."
46
+
```
47
+
41
48
You can also set a tracing API key per run without changing the global exporter.
0 commit comments