Skip to content

[FEATURE]: create and expose model-id environment variables for bash from CLI #10453

@bdwelle

Description

@bdwelle

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I have shell scripts and other code that runs from opencode (agents, skills, and tools) that need to be aware of which model the user has selected, for model-aware workflows.

For one, I want to be able to compare content generated by different models, and include model id / name in frontmatter.

Having the id of the currently selected model available also enables patterns like this -- using the SDK to query whatever model the user currently has selected in the TUI:

    const result = await opencodeClient.session.prompt({
      path: { id: session.data.id },
      body: {
        model: {
          providerID: process.env.OPENCODE_PROVIDER_ID,
          modelID: process.env.OPENCODE_MODEL_ID,
        },
        parts: [
          {
            type: "text",
            text: prompt,
          },
        ],
      },
    });

I see a few other feature requests that could be solved by this:
#10453
#10247
#6350
#9065
#9292
#7492

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions