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

# CodeBuddy / WorkBuddy

> Connect CodeBuddy or WorkBuddy to AihubMax via models.json configuration

## Overview

[CodeBuddy](https://codebuddy.ai) and [WorkBuddy](https://workbuddy.ai) are AI-powered coding assistants developed by Tencent Cloud that integrate directly into your IDE. By connecting them to AihubMax, you can leverage a wide selection of AI models through AihubMax's unified API.

<Info>
  CodeBuddy and WorkBuddy use a `models.json` configuration file to define custom model providers. AihubMax's OpenAI-compatible endpoint works seamlessly with this configuration method.
</Info>

## Prerequisites

<CardGroup cols={2}>
  <Card title="AihubMax API Key" icon="key">
    An active AihubMax API key with access to the models you want to use.
  </Card>

  <Card title="CodeBuddy / WorkBuddy" icon="code">
    The CodeBuddy or WorkBuddy extension installed in your IDE (VS Code, JetBrains, etc.).
  </Card>
</CardGroup>

## Configuration

CodeBuddy and WorkBuddy read model definitions from a `models.json` file. There are two levels of configuration:

* **User-level** (applies to all projects): stored in your home directory
* **Project-level** (higher priority, applies to a single project): stored in the project root

<Steps>
  <Step title="Locate the Configuration File">
    Choose the appropriate path based on your tool and operating system:

    <Tabs>
      <Tab title="CodeBuddy">
        | Level       | macOS / Linux                           | Windows                                      |
        | ----------- | --------------------------------------- | -------------------------------------------- |
        | **User**    | `~/.codebuddy/models.json`              | `C:\Users\<username>\.codebuddy\models.json` |
        | **Project** | `<project-root>/.codebuddy/models.json` | `<project-root>\.codebuddy\models.json`      |
      </Tab>

      <Tab title="WorkBuddy">
        | Level       | macOS / Linux                           | Windows                                      |
        | ----------- | --------------------------------------- | -------------------------------------------- |
        | **User**    | `~/.workbuddy/models.json`              | `C:\Users\<username>\.workbuddy\models.json` |
        | **Project** | `<project-root>/.workbuddy/models.json` | `<project-root>\.workbuddy\models.json`      |
      </Tab>
    </Tabs>

    <Tip>
      Project-level configuration takes priority over user-level. Use project-level config when you need different models or API keys for specific projects.
    </Tip>
  </Step>

  <Step title="Create the models.json File">
    Create the `models.json` file at the path from the previous step. Here is a basic example with one model:

    ```json theme={null}
    {
      "models": [
        {
          "id": "gpt-5.4",
          "name": "AihubMax Auto (Smart Routing)",
          "vendor": "AihubMax",
          "apiKey": "sk-your-foxapi-api-key",
          "url": "https://api.aihubmax.com/v1/chat/completions",
          "supportsToolCall": true,
          "supportsImages": true
        }
      ]
    }
    ```

    Replace `sk-your-foxapi-api-key` with your actual AihubMax API key.

    <Warning>
      The URL must be the full chat completions endpoint: `https://api.aihubmax.com/v1/chat/completions`. Do not use just the base URL.
    </Warning>
  </Step>

  <Step title="Add More Models (Optional)">
    You can define multiple models in the `models` array. Each entry appears as a selectable model in the extension:

    ```json theme={null}
    {
      "models": [
        {
          "id": "gpt-5.4",
          "name": "AihubMax Auto (Smart Routing)",
          "vendor": "AihubMax",
          "apiKey": "sk-your-foxapi-api-key",
          "url": "https://api.aihubmax.com/v1/chat/completions",
          "supportsToolCall": true,
          "supportsImages": true
        },
        {
          "id": "claude-sonnet-4-20250514",
          "name": "Claude Sonnet 4",
          "vendor": "AihubMax",
          "apiKey": "sk-your-foxapi-api-key",
          "url": "https://api.aihubmax.com/v1/chat/completions",
          "supportsToolCall": true,
          "supportsImages": true
        },
        {
          "id": "gpt-4o",
          "name": "GPT-4o",
          "vendor": "AihubMax",
          "apiKey": "sk-your-foxapi-api-key",
          "url": "https://api.aihubmax.com/v1/chat/completions",
          "supportsToolCall": true,
          "supportsImages": true
        },
        {
          "id": "deepseek-chat",
          "name": "DeepSeek V3",
          "vendor": "AihubMax",
          "apiKey": "sk-your-foxapi-api-key",
          "url": "https://api.aihubmax.com/v1/chat/completions",
          "supportsToolCall": true,
          "supportsImages": false
        }
      ]
    }
    ```

    Refer to [AihubMax's model list](/models) for all available model IDs.
  </Step>

  <Step title="Select the Model in Your IDE">
    After saving the `models.json` file, the extension auto-detects the changes -- no restart required. Open CodeBuddy or WorkBuddy in your IDE and select one of the AihubMax models you configured from the model dropdown.
  </Step>
</Steps>

## Configuration Reference

Each model entry in `models.json` supports the following fields:

| Field              | Type    | Required | Description                                                                        |
| ------------------ | ------- | -------- | ---------------------------------------------------------------------------------- |
| `id`               | string  | Yes      | The model identifier sent to the API (e.g., `gpt-4o`, `claude-sonnet-4-20250514`). |
| `name`             | string  | Yes      | Display name shown in the model selector.                                          |
| `vendor`           | string  | Yes      | A label for the provider (e.g., `AihubMax`).                                       |
| `apiKey`           | string  | Yes      | Your AihubMax API key.                                                             |
| `url`              | string  | Yes      | The full chat completions endpoint URL.                                            |
| `supportsToolCall` | boolean | No       | Set to `true` if the model supports function/tool calling.                         |
| `supportsImages`   | boolean | No       | Set to `true` if the model supports image inputs.                                  |

## Verify the Connection

After configuring `models.json`:

1. Open any code file in your IDE.
2. Select one of your AihubMax models from the model dropdown.
3. Trigger the AI assistant (e.g., select code and ask for an explanation, or start an inline chat).
4. If the response is generated successfully, the connection is working.

## Troubleshooting

<AccordionGroup>
  <Accordion title="No response from the AI assistant">
    * Verify your API key is correct and has sufficient balance.
    * Check that the `url` field is exactly `https://api.aihubmax.com/v1/chat/completions`.
    * Ensure the `id` field matches a model available on AihubMax.
    * Validate the JSON syntax of your `models.json` file (no trailing commas, proper quoting).
  </Accordion>

  <Accordion title="Models not appearing in the dropdown">
    * Confirm the `models.json` file is in the correct directory (see [Locate the Configuration File](#locate-the-configuration-file)).
    * The extension auto-detects file changes, but try restarting the extension or IDE if models still do not appear.
    * Ensure the JSON file is valid. You can check with:
      ```bash theme={null}
      cat ~/.codebuddy/models.json | python3 -m json.tool
      ```
  </Accordion>

  <Accordion title="Slow response times">
    * Try switching to a faster model (e.g., `claude-sonnet-4-20250514` instead of `claude-opus-4-20250514`).
    * Check your network connection.
  </Accordion>

  <Accordion title="Tool calling or image features not working">
    * Ensure `supportsToolCall` and/or `supportsImages` are set to `true` in your model entry.
    * Not all models support these features. Check the model's capabilities on AihubMax's model list.
  </Accordion>
</AccordionGroup>

## Security Best Practices

<Note>
  * **Never commit `models.json` to version control** if it contains your API key. Add `.codebuddy/` and `.workbuddy/` to your `.gitignore` file.
  * **Use project-level config with caution.** If working in a shared repository, prefer user-level configuration to avoid accidentally exposing your API key.
  * **Monitor usage** on your AihubMax dashboard to detect any unexpected consumption.
</Note>
