---
title: "Configure a model provider"
description: "Create a local gateway upstream, switch a CLI onto it, and verify that requests pass through OcHub."
version: "en"
---

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

# Configure a model provider

Model provider mode points a tool at OcHub's local gateway, which then sends requests to
the active upstream. You can switch upstreams without repeatedly rewriting tool
configuration, while centralizing protocol conversion, model mapping, and usage
tracking.

## Use this path when

- Several tools should share the same upstream.
- The client and upstream use different API interfaces.
- You need model aliases, reasoning normalization, usage accounting, or a
  prepared backup upstream.

For one endpoint in one tool, a [direct connection](/getting-started/direct-connection)
has fewer moving parts.

## Create a model provider

1. **Open Model providers.** If compatible local configuration already contains
   an API key, try **Import from existing configuration** first.

2. **Add a model provider.** Enter a name, upstream API origin, and access key.
   Enter the origin without a trailing `/v1` — OcHub appends the per-interface
   request path (such as `/v1/messages`) itself.

3. **Detect interfaces.** Select **Detect** to probe Anthropic Messages, OpenAI
   Chat, and OpenAI Responses. If automatic detection fails, enable only the
   interfaces documented by the upstream.

4. **Keep the first setup simple.** Leave the default model, model exceptions,
   and custom reasoning budgets empty.

5. **Save and review the card.** Before saving, the editor's **HTTP latency
   test** confirms the address is reachable; after saving, check the card's
   interface chips, model count, and on/off state. Reachability does not prove
   that authentication or a real model request will succeed.

6. **Switch a tool onto it.** Open the target app page (Codex, Claude Code, …)
   and select **Switch** on the entry under **Model provider mode**. The entry
   is then marked **Current** with an **In use** button, and the tool's live
   configuration points to the local gateway.

## Switch model providers

Model providers are switched from the app page as well:

1. On the target app page, choose an enabled provider in the **Model provider
   mode** section (the **Active model provider** panel once one is applied).
2. Switching now updates only the local route instead of repeatedly rewriting
   tool configuration.
3. The **Active model provider** panel marks the one in use and shows its
   default model or number of model mappings.

## Verify the request path

- Start the target CLI and make a short request.
- In **Usage → Request logs**, find an entry whose source is Model provider
  request.
- Open it and verify the request model, pricing model, provider, status, and
  latency.

If the tool cannot connect, first confirm that OcHub is still running, then
check that the model provider is enabled.

## Connect another local tool

The **Connect other tools** section provides a loopback URL and local key. Any
local client that supports OpenAI Chat can use them.

> **The local key is not the upstream key**
>
> OcHub generates and validates this key on the local machine. It cannot be used
> on another computer or with the upstream service. Do not expose the loopback
> listener to the public internet.

## Disconnect or restore direct mode

- Delete the connection that points at the model provider on the app's
  Connections page to remove that app's relation to it.
- A model provider in use cannot be deleted; the dialog lists the affected
  apps. Switch those apps to another model provider or a direct connection
  first.
- Disabling a model provider in use immediately breaks those tool requests;
  switch the affected apps first.
- To return to direct mode, switch to a direct connection on the app page.

For model mappings, interface exceptions, and backup-upstream workflows, read
[Routing recipes](/advanced/routing-recipes).

Source: https://docs.ochub.org/getting-started/relay/index.mdx
