Skip to main content
A ready-to-run example is available here!
The Settings and Secrets API provides REST endpoints for managing agent configuration and custom secrets through a local agent server. This is the recommended pattern for frontend clients that need to:
  • Store secrets securely via the Settings API (encrypted at rest)
  • Pass encrypted secrets when starting conversations via secrets_encrypted=True
  • Never have access to plaintext secrets after initial storage

Key Concepts

Settings Endpoints

The agent server exposes settings management via REST:
  • GET /api/settings - Retrieve current settings
  • PATCH /api/settings - Update settings with a partial diff

Encrypted Secrets for Starting Conversations

Frontend clients use the X-Expose-Secrets: encrypted header to get cipher-encrypted secrets:
Then use the encrypted LLM config when starting a conversation:
The server decrypts the secrets before using them, ensuring the frontend never has access to plaintext secrets after initial storage.

Custom Secrets CRUD Operations

Custom secrets can be created, listed, retrieved, and deleted:

Secret Name Validation

Secret names must follow environment variable naming conventions:
  • Start with a letter (a-z, A-Z)
  • Contain only letters, numbers, and underscores
  • Be 1-64 characters long
Invalid names are rejected with a 422 response:

Ready-to-Run Example

This example demonstrates the complete encrypted secrets workflow:
  1. Store LLM API key via PATCH /api/settings (encrypted at rest)
  2. Fetch settings with X-Expose-Secrets: encrypted header
  3. Start conversation via POST /api/conversations with secrets_encrypted=True
  4. Poll conversation state and verify agent task completion
  5. Test custom secrets CRUD operations
examples/02_remote_agent_server/12_settings_and_secrets_api.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Next Steps