> ## Documentation Index
> Fetch the complete documentation index at: https://opencomputer.manicule.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://opencomputer.manicule.dev/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://opencomputer.manicule.dev/api/mcp.
> Every agent surface: https://opencomputer.manicule.dev/.well-known/llms-manifest.json

# Models (/agents/models)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 590 · updated: 2026-08-25 -->
Related: [Serverless Agents](/agents/overview.md), [How it works](/agents/mental-model.md), [Quickstart](/agents/quickstart.md), [Projects and agents](/agents/projects.md), [Reactive agents](/agents/reactive-agents.md), [Sessions and turns](/agents/sessions.md)

> Select a model with useModel

`useModel()` selects the model that powers the next agent step. OpenComputer
handles provider authentication and response streaming.

```tsx
import { useModel } from "@opencomputer/agent";

export default function Agent() {
  useModel("anthropic/claude-sonnet-4.6");
  return "You are a helpful assistant. Be concise and practical.";
}
```

`useModel()` is a declaration. It returns nothing and does not make a model
request itself.

## Model identifiers

Use a `provider/model` string:

```tsx
useModel("anthropic/claude-sonnet-4.6");
```

The object form is equivalent:

```tsx
useModel({
  provider: "anthropic",
  model: "claude-sonnet-4.6",
});
```

Keep model selection in agent code so development and immutable deployments
record the behavior together. Provider credentials are not added to source
bundles or client applications.

## Select a model conditionally

Because the agent re-renders for each model step, selection can respond to the
current input:

```tsx
import { useInput, useModel } from "@opencomputer/agent";

export default function Agent() {
  const input = useInput();
  const needsDeepReview = input.text?.includes("deep review") ?? false;

  useModel(
    needsDeepReview
      ? "anthropic/claude-sonnet-4.6"
      : "anthropic/claude-haiku-4.5",
  );

  return needsDeepReview
    ? "Review the request carefully and explain important tradeoffs."
    : "Answer directly and briefly.";
}
```

Select one model for the next step and keep the choice predictable: model
changes affect cost, latency, context limits, and output behavior.

## Keep credentials out of agent code

Do not place provider API keys in `agent.ts`, tools, prompts, or the React
application. OpenComputer authenticates the selected provider without adding
the credential to agent code.

For credentials used by your own HTTP tools instead of model inference, use
[Secrets and outbound requests](/agents/secrets).

## Use a connected model account

Organizations on Pro or Max can connect a Codex account and route eligible
OpenAI models through it. Use the native `openai` provider when you want the
connected account; Managed OpenRouter models continue to use the
`openrouter/provider/model` form.

See [Bring your own model account (BYOK)](/agents/byok) for setup, project
enablement, billing behavior, and troubleshooting.
