# default LLM model (app.DefaultModel)

> Declares the app's default LLM — the provider, model, API-key secret, and optional endpoint — as a single app-level config. `Provider` is one of `LlmProvider.Anthropic | OpenAI | Gemini | OpenAICompatible`; the API key is a `Secret.X` handle declared in `app.Secrets`. A singleton: declaring it twice is a compile error, and removing it clears the default.

<!-- id: agent-default-model · area: agent · stability: preview · html: https://osysharp.com/reference/agent/default-model/ -->

## Summary        {#summary}
`app.DefaultModel` declares the application's default large-language model as one app-level config block. You name a
**provider**, a **model** string, the **API key** (a `Secret.X` handle), and an optional custom **BaseUrl**. It is a
per-app **singleton** — declared once — and it self-reconciles against source: removing it clears the default.

```osy syntax
app.Secrets = [ new Secret("Anthropic") ];
app.DefaultModel = new LlmConfig {
  Provider = LlmProvider.Anthropic,
  Model    = "claude-opus-4-8",
  ApiKey   = Secret.Anthropic,
};
```

## Signature      {#signature}
```osy
app.Secrets = [ new Secret("Anthropic") ];   // the handle the config below reads

app.DefaultModel = new LlmConfig {
  Provider = LlmProvider.Anthropic,   // Anthropic | OpenAI | Gemini | OpenAICompatible
  Model    = "claude-opus-4-8",       // the provider's model id
  ApiKey   = Secret.Anthropic,        // a handle declared in app.Secrets
  BaseUrl  = "https://api.anthropic.com",  // optional — required for OpenAICompatible
};
```

A single app-level assignment. It is a singleton — declaring it twice is a compile error.

## Description    {#description}
`LlmConfig` has four members:

- **`Provider`** — a qualified `LlmProvider` enum member. `Anthropic`, `OpenAI`, and `Gemini` are first-party
  providers reached at their default endpoints. `OpenAICompatible` targets any OpenAI-wire-compatible server (a
  self-hosted model, a proxy, or an OpenRouter-style gateway) and **requires** a `BaseUrl`.
- **`Model`** — the provider's model identifier (e.g. `claude-opus-4-8`, `gpt-4o`, `gemini-2.5-flash`).
- **`ApiKey`** — a `Secret.X` handle. The secret must be declared in [`app.Secrets`](https://osysharp.com/reference/config/secrets/); the key is
  resolved at runtime from the secret store and never inlined in source.
- **`BaseUrl`** *(optional)* — a custom endpoint. Optional for the first-party providers (they default to their own
  endpoints); required for `OpenAICompatible`.

Because it self-reconciles against source, the config behaves like a switch: **declaring it** upserts the singleton,
**removing it** sweeps the row and clears the app default (no prune step needed). Every LLM call the platform makes on
your behalf is metered against your budget regardless of which provider you choose.

## Examples       {#examples}
Point the app at an OpenAI-compatible endpoint you host yourself — `OpenAICompatible` plus a `BaseUrl`:

```osy title="default-model-openai-compatible" test app=default-model-openai-compatible
app.Secrets = [ new Secret("LocalLlm") ];
app.DefaultModel = new LlmConfig {
  Provider = LlmProvider.OpenAICompatible,
  Model    = "llama-3.1-70b",
  ApiKey   = Secret.LocalLlm,
  BaseUrl  = "https://llm.internal.example.com/v1",
};
```

## See also       {#see-also}
- [[Searchable]](https://osysharp.com/reference/memory/searchable/) — `[Searchable]`, the field-search surface; semantic ranking uses the app embedding configured the same way
