# How to Configure LLM Backends (OpenAI, Qwen, DeepInfra) in Chat-MCP

> Discover how to configure diverse LLM backends like OpenAI, Qwen, and DeepInfra in Chat-MCP using simple JSON files. Connect seamlessly without code changes.

- Repository: [AIQL/chat-mcp](https://github.com/ai-ql/chat-mcp)
- Tags: how-to-guide
- Published: 2026-02-23

---

**Chat-MCP uses provider-agnostic JSON configuration files to connect to any OpenAI-compatible API, including OpenAI, Qwen, and DeepInfra, without modifying the application source code.**

The Chat-MCP desktop application decouples LLM providers from the core client through a flexible configuration system. Instead of hard-coding API endpoints, the application reads backend definitions from JSON files at runtime, enabling seamless switching between OpenAI, Alibaba DashScope (Qwen), DeepInfra, and other compatible providers.

## Understanding the Backend Configuration Schema

Each LLM backend requires a JSON file containing two primary objects: `chatbotStore` and `defaultChoiceStore`. The `chatbotStore` object defines the API connection parameters, while `defaultChoiceStore` lists available models for the UI dropdown.

The `chatbotStore` schema includes:

- **apiKey**: Authentication token for the provider API
- **url**: Base endpoint URL for the provider
- **path**: Specific API path for chat completions (typically `/v1/chat/completions`)
- **model**: Default model identifier string
- **max_tokens_value**: Optional token limit (empty string for provider defaults)
- **mcp**: Boolean flag set to `true` to indicate OpenAI-compatible MCP schema compliance

## Step-by-Step Configuration for Each Provider

### OpenAI and OpenAI-Compatible APIs

To configure OpenAI or any OpenAI-compatible service (such as Azure OpenAI or local LLM servers), create a JSON file with the following structure:

```json
{
  "chatbotStore": {
    "apiKey": "",
    "url": "https://api.aiql.com",
    "path": "/v1/chat/completions",
    "model": "gpt-4o-mini",
    "max_tokens_value": "",
    "mcp": true
  },
  "defaultChoiceStore": {
    "model": [
      "gpt-4o-mini",
      "gpt-4o",
      "gpt-4",
      "gpt-4-turbo"
    ]
  }
}

```

Replace the `url` with `https://api.openai.com` for official OpenAI services, and populate the `apiKey` field with your actual API key. The `mcp: true` flag ensures the Chat-MCP client interprets responses according to the MCP-compatible OpenAI schema.

### Qwen via Alibaba DashScope

For Alibaba's Qwen models accessed through the DashScope API, use the following configuration template:

```json
{
  "chatbotStore": {
    "apiKey": "",
    "url": "https://dashscope.aliyuncs.com/compatible-mode",
    "path": "/v1/chat/completions",
    "model": "qwen-turbo",
    "max_tokens_value": "",
    "mcp": true
  },
  "defaultChoiceStore": {
    "model": [
      "qwen-turbo",
      "qwen-plus",
      "qwen-max"
    ]
  }
}

```

The `compatible-mode` endpoint provides OpenAI API compatibility, allowing Chat-MCP to communicate with Qwen models using the same client logic as OpenAI. Obtain your API key from the Alibaba Cloud DashScope console and insert it into the `apiKey` field.

### DeepInfra for Meta Llama Models

To configure DeepInfra for hosting Meta's Llama models or other open-source LLMs, implement this JSON structure:

```json
{
  "chatbotStore": {
    "apiKey": "",
    "url": "https://api.deepinfra.com",
    "path": "/v1/openai/chat/completions",
    "model": "meta-llama/Meta-Llama-3.1-70B-Instruct",
    "max_tokens_value": "32000",
    "mcp": true
  },
  "defaultChoiceStore": {
    "model": [
      "meta-llama/Meta-Llama-3.1-70B-Instruct",
      "meta-llama/Meta-Llama-3.1-405B-Instruct",
      "meta-llama/Meta-Llama-3.1-8B-Instruct"
    ]
  }
}

```

DeepInfra uses a nested path structure (`/v1/openai/chat/completions`) to maintain OpenAI compatibility. The `max_tokens_value` field accepts specific numeric limits, such as `32000` for the 70B Llama model context window.

## How Chat-MCP Loads Backend Configurations

The application implements a runtime configuration system in [`src/main/main.ts`](https://github.com/ai-ql/chat-mcp/blob/main/src/main/main.ts) that dynamically loads backend definitions without requiring recompilation.

The `readConfig` helper function (lines 44-52 in [`src/main/main.ts`](https://github.com/ai-ql/chat-mcp/blob/main/src/main/main.ts)) reads the JSON configuration from the application directory:

```typescript
// Located in src/main/main.ts
import { readFileSync } from 'fs';
import * as path from 'path';

function readConfig(appPath: string) {
  const configPath = path.join(appPath, 'config.json');
  const configData = readFileSync(configPath, 'utf8');
  return JSON.parse(configData);
}

```

While [`src/main/config.json`](https://github.com/ai-ql/chat-mcp/blob/main/src/main/config.json) defines which MCP servers to launch (such as `server-everything` via `npx`), the actual LLM backend settings reside in separate JSON files that you create using the templates above. The [`src/main/client.ts`](https://github.com/ai-ql/chat-mcp/blob/main/src/main/client.ts) file instantiates the MCP client that communicates with the chosen backend using the parameters defined in your configuration.

To switch backends, place your provider-specific JSON file in the application directory and reference it when launching the MCP server. The desktop app reads the updated backend definition on startup and exposes the new model through the UI dropdown populated by `defaultChoiceStore`.

## Summary

- Chat-MCP uses **provider-agnostic JSON configuration files** to connect to OpenAI, Qwen, DeepInfra, and other OpenAI-compatible APIs.
- Each configuration requires `chatbotStore` for connection parameters and `defaultChoiceStore` for UI model options.
- The `mcp: true` flag enables OpenAI-style schema compatibility for all supported providers.
- Configuration files are loaded at runtime by [`src/main/main.ts`](https://github.com/ai-ql/chat-mcp/blob/main/src/main/main.ts), allowing backend switches without code changes.
- Specific endpoints vary by provider: OpenAI uses `api.openai.com`, Qwen uses `dashscope.aliyuncs.com/compatible-mode`, and DeepInfra uses `api.deepinfra.com/v1/openai`.

## Frequently Asked Questions

### Where do I place the LLM backend configuration file?

Place the JSON configuration file in the application directory where [`src/main/main.ts`](https://github.com/ai-ql/chat-mcp/blob/main/src/main/main.ts) can access it via the `readConfig` helper. The app loads the file at startup to establish the connection to your chosen LLM provider. Ensure the file follows the schema with `chatbotStore` and `defaultChoiceStore` objects to prevent parsing errors.

### Can I use a local LLM server with Chat-MCP?

Yes, any OpenAI-compatible API server works with Chat-MCP. Configure the `url` field to point to your local server address (such as `http://localhost:8000`), set the `path` to `/v1/chat/completions`, and ensure `mcp` is set to `true`. The application will treat your local endpoint exactly like a cloud provider, enabling offline development with models served via Ollama, LM Studio, or similar tools.

### How do I switch between different LLM providers without restarting the app?

Currently, Chat-MCP reads the backend configuration during the main process startup in [`src/main/main.ts`](https://github.com/ai-ql/chat-mcp/blob/main/src/main/main.ts). To switch providers, you must create a new JSON configuration file with the desired `chatbotStore` settings and restart the application. The `defaultChoiceStore` will populate the UI dropdown with the new provider's model list upon restart, allowing immediate selection of the updated backend.