For the complete documentation index, see llms.txt. This page is also available as Markdown.

Profiles

Name a provider, model, params and key once, then select it by name.

A profile is a named combination of provider, model, params, options and API key. Define fast and planner once, then pick one per call, per agent, or per run. Without profiles, nothing changes.

πŸ› οΈ Define

In boxlang.json:

{
  "modules": { "bxai": { "settings": {
    "provider": "openai",
    "profiles": {
      "fast": {
        "description": "Cheap and quick, for small tasks",
        "provider": "openai",
        "model": "gpt-4.1-mini",
        "params": { "temperature": 0 },
        "apiKeyEnv": "OPENAI_API_KEY"
      },
      "planner": {
        "description": "Slower and smarter, for planning",
        "provider": "claude",
        "model": "claude-opus-5-5",
        "params": { "temperature": 0.7, "max_tokens": 8192 },
        "apiKeyEnv": "CLAUDE_API_KEY"
      }
    },
    "defaultProfile": ""
  } } }
}
Key
Meaning

description

Free text for people and UIs. Returned by aiProfile() and aiProfiles()

provider

Provider key. Empty uses the top level provider

model

Shorthand for params.model

params

Request params for this profile

options

Request options for this profile, such as timeout

apiKeyEnv

The name of the environment variable that holds the key. Preferred

apiKey

A literal key. Avoid it

The profile default always exists. It is your top level provider, apiKey and defaultParams. Set defaultProfile to make another profile the one used when a call names no provider.

Rules, checked when the module starts: a profile cannot be named like a provider (openai, claude, ...) or default, names use letters, numbers, _ and -, and defaultProfile must exist. A broken setting throws InvalidConfiguration.

🎯 Use

An explicit provider, key, param or option in the call always wins. Params layer from lowest to highest: defaultParams, providers.<name>.params, the profile, the call. An unknown profile throws ProfileNotFound.

Pass either model or profile to aiAgent(), not both.

Profiles cover chat, streaming and embeddings. Audio (aiSpeak(), aiTranscribe(), aiTranslate()) and images (aiImage()) keep using the audio and image settings.

πŸ”€ Switch an agent

The middleware, skills and MCP servers of the agent's model also stay. agent.setModel( model ) sets the profile to the one the new model was built from, or empty when it has none.

stream() takes the same profile option. To give a sub-agent its own profile, create it with one: aiAgent( name: "researcher", profile: "planner" ), then pass it in subAgents.

πŸ“‹ List

Built for chat UIs and remote control, such as /profile and /provider commands:

πŸ” Keys stay secret

  • Use apiKeyEnv. The key is read from the environment when the profile is used.

  • Listings return hasApiKey and the variable name, never the key. Params and options that look like secrets (key, token, secret, password) show as ****.

  • A profile key is only sent to the profile's own provider. The same goes for its params (including its model) and options: aiChat( "Hi", {}, { profile: "fast", provider: "claude" } ) sends none of them to Claude.

  • Profiles are never copied into request options, so they do not reach logs or events.

πŸ“‘ Event

onAIProfileSwitch fires when an agent changes profile. See events.

Last updated