Skip to main content
A ready-to-run example is available here!
The LLMProfileStore class provides a centralized mechanism for managing LLM configurations. Define a profile once, reuse it everywhere — across scripts, sessions, and even machines.

Benefits

  • Persistence: Saves model parameters (API keys, temperature, max tokens, …) to a stable disk format.
  • Reusability: Import a defined profile into any script or session with a single identifier.
  • Portability: Simplifies the synchronization of model configurations across different machines or deployment environments.

How It Works

1

Create a Store

The store manages a directory of JSON profile files. By default it uses ~/.openhands/profiles, but you can point it anywhere.
2

Save a Profile

Got an LLM configured just right? Save it for later.
Secret fields are masked by default for security, so the saved JSON keeps the field shape without exposing the real value. Pass include_secrets=True to persist the actual secret values.
3

Load a Profile

Next time you need that LLM, just load it:
4

List and Clean Up

See what you’ve got, delete what you don’t need:

Good to Know

Profile names must be simple filenames (no slashes, no dots at the start).

Ready-to-run Example

This example is available on GitHub: examples/01_standalone_sdk/37_llm_profile_store/main.py
This directory-based example ships with a pre-generated profiles/fast.json file created from a normal save, then creates a second profile at runtime in a temporary store.
examples/01_standalone_sdk/37_llm_profile_store/main.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.

Mid-Conversation Model Switching

You can use a saved profile to switch the active model on a running conversation between turns. This is useful when you want to start with one model, then switch to another for later user messages while keeping the same conversation history and combined usage metrics.
examples/01_standalone_sdk/44_model_switching_in_convo.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.

Agent-Driven LLM Switching

Saved profiles can also be exposed to the agent through the switch_llm built-in tool. The tool call switches the conversation’s active profile after the current model finishes the tool call, so future model calls use the selected profile.
This example is available on GitHub: examples/01_standalone_sdk/49_switch_llm_tool.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