> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hrns.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Provider setup

> Configure hrns to talk to an OpenAI-compatible chat completion endpoint.

## Supported configuration

The bundled TUI stores provider settings in:

```text theme={null}
~/.config/hrns/config.json
```

If the file does not exist, startup falls back to an interactive onboarding flow.

## First-run onboarding

On the first launch, `hrns` prompts for:

* provider name
* provider API URL
* provider API key
* default model
* whether to skip TLS verification

The entered provider is saved and becomes `currentProvider`.

## Config shape

The current file format looks like this:

```json theme={null}
{
  "providers": {
    "openai": {
      "url": "https://api.openai.com/v1",
      "key": "your-api-key",
      "model": "your-model",
      "skipVerify": false
    }
  },
  "currentProvider": "openai"
}
```

For the active provider, `tui.Run` builds `openai.NewClient(...)` with:

* `url` as the OpenAI-compatible base URL
* `key` as the bearer token
* `skipVerify` to control TLS verification
* `model` as the startup model shown in the TUI

## Typical setups

### Default OpenAI-style base URL

Use onboarding and enter:

* provider name: `openai`
* provider API URL: `https://api.openai.com/v1`
* provider API key: your API key
* default model: a model your provider supports
* skip TLS verify: `n`

### Custom endpoint

Use onboarding and enter your endpoint URL and model.

### Local endpoint with self-signed TLS

Set:

* provider API URL: `https://localhost:8443/v1`
* provider API key: your development key
* skip TLS verify: `y`

## Important runtime detail

Provider configuration and model selection are separate concerns.

You can inspect the models exposed by the current provider with:

```text theme={null}
/models
```

You can change the saved model for the current provider at runtime:

```text theme={null}
/model <your-model>
```

You can also add more providers with:

```text theme={null}
/connect
```

To switch the active session to a saved provider:

```text theme={null}
/provider <name>
```

`/connect` saves the new provider and marks it as `currentProvider` in the config file, but it does not rebuild the in-memory client by itself. Use `/provider <name>` to switch immediately, or restart the TUI to start with the saved current provider.

In `hrns exec`, `-provider <name>` uses that provider's saved default model unless you also pass `-model`.

## When embedding instead of using the TUI

If you use the packages directly, you do not need the TUI config file at all. You can build the client explicitly:

```go theme={null}
client := openai.NewClient(
    openai.WithBaseURL("https://your-provider.example/v1"),
    openai.WithAPIKey("your-api-key"),
)
```

That is usually the cleaner path for real applications.
