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/config.md
+28-6Lines changed: 28 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## API keys and clients
4
4
5
-
By default, the SDK looks for the `OPENAI_API_KEY` environment variable for LLM requests and tracing, as soon as it is imported. If you are unable to set that environment variable before your app starts, you can use the [set_default_openai_key()][agents.set_default_openai_key] function to set the key.
5
+
By default, the SDK uses the `OPENAI_API_KEY` environment variable for LLM requests and tracing. The key is resolved when the SDK first creates an OpenAI client (lazy initialization), so set the environment variable before your first model call. If you are unable to set that environment variable before your app starts, you can use the [set_default_openai_key()][agents.set_default_openai_key] function to set the key.
6
6
7
7
```python
8
8
from agents import set_default_openai_key
@@ -65,6 +65,26 @@ from agents import set_tracing_disabled
65
65
set_tracing_disabled(True)
66
66
```
67
67
68
+
If you want to keep tracing enabled but exclude potentially sensitive inputs/outputs from trace payloads, set [`RunConfig.trace_include_sensitive_data`][agents.run.RunConfig.trace_include_sensitive_data] to `False`:
For full tracing controls, see the [tracing guide](tracing.md).
87
+
68
88
## Debug logging
69
89
70
90
The SDK defines two Python loggers (`openai.agents` and `openai.agents.tracing`) and does not attach handlers by default. Logs follow your application's Python logging configuration.
Certain logs may contain sensitive data (for example, user data). If you want to disable this data from being logged, set the following environment variables.
121
+
Certain logs may contain sensitive data (for example, user data).
102
122
103
-
To disable logging LLM inputs and outputs:
123
+
By default, the SDK does **not** log LLM inputs/outputs or tool inputs/outputs. These protections are controlled by:
104
124
105
125
```bash
106
-
export OPENAI_AGENTS_DONT_LOG_MODEL_DATA=1
126
+
OPENAI_AGENTS_DONT_LOG_MODEL_DATA=1
127
+
OPENAI_AGENTS_DONT_LOG_TOOL_DATA=1
107
128
```
108
129
109
-
To disable logging tool inputs and outputs:
130
+
If you need to include this data temporarily for debugging, set either variable to `0` (or `false`) before your app starts:
result =await Runner.run(agent, "Hello", session=session)
240
+
```
241
+
242
+
### Redis sessions
243
+
244
+
Use `RedisSession` for shared session memory across multiple workers or services.
245
+
246
+
```bash
247
+
pip install openai-agents[redis]
248
+
```
249
+
250
+
```python
251
+
from agents import Agent, Runner
252
+
from agents.extensions.memory import RedisSession
253
+
254
+
agent = Agent(name="Assistant")
255
+
session = RedisSession.from_url(
256
+
"user_123",
257
+
url="redis://localhost:6379/0",
258
+
)
259
+
result =await Runner.run(agent, "Hello", session=session)
260
+
```
261
+
225
262
### SQLAlchemy sessions
226
263
227
264
Production-ready sessions using any SQLAlchemy-supported database:
@@ -315,12 +352,13 @@ Use meaningful session IDs that help you organize conversations:
315
352
316
353
- Use in-memory SQLite (`SQLiteSession("session_id")`) for temporary conversations
317
354
- Use file-based SQLite (`SQLiteSession("session_id", "path/to/db.sqlite")`) for persistent conversations
355
+
- Use async SQLite (`AsyncSQLiteSession("session_id", db_path="...")`) when you need an `aiosqlite`-based implementation
356
+
- Use Redis-backed sessions (`RedisSession.from_url("session_id", url="redis://...")`) for shared, low-latency session memory
318
357
- Use SQLAlchemy-powered sessions (`SQLAlchemySession("session_id", engine=engine, create_tables=True)`) for production systems with existing databases supported by SQLAlchemy
319
-
- Use Dapr state store sessions (`DaprSession.from_address("session_id", state_store_name="statestore", dapr_address="localhost:50001")`) for production cloud-native deployments with support for
320
-
30+ database backends with built-in telemetry, tracing, and data isolation
358
+
- Use Dapr state store sessions (`DaprSession.from_address("session_id", state_store_name="statestore", dapr_address="localhost:50001")`) for production cloud-native deployments with support for 30+ database backends with built-in telemetry, tracing, and data isolation
321
359
- Use OpenAI-hosted storage (`OpenAIConversationsSession()`) when you prefer to store history in the OpenAI Conversations API
322
360
- Use encrypted sessions (`EncryptedSession(session_id, underlying_session, encryption_key)`) to wrap any session with transparent encryption and TTL-based expiration
323
-
- Consider implementing custom session backends for other production systems (Redis, Django, etc.) for more advanced use cases
361
+
- Consider implementing custom session backends for other production systems (for example, Django) for more advanced use cases
324
362
325
363
### Multiple sessions
326
364
@@ -493,6 +531,8 @@ For detailed API documentation, see:
493
531
-[`OpenAIConversationsSession`][agents.memory.OpenAIConversationsSession] - OpenAI Conversations API implementation
494
532
-[`OpenAIResponsesCompactionSession`][agents.memory.openai_responses_compaction_session.OpenAIResponsesCompactionSession] - Responses API compaction wrapper
0 commit comments