# Welcome to TensorX

**TensorX** is an AI inference platform that gives developers access to powerful open-source models through simple, familiar APIs.

Use cutting-edge models like **GLM-5.1**, **MiniMax-M2**, and **MiniMax-M2.5** with your existing tools - no code changes required.

## Why TensorX?

* 🚀 **Powerful open-source models** - GLM-5.1, MiniMax-M2.5, MiniMax-M2, and more
* 💰 **Pay-as-you-go pricing** - Only pay for what you use
* ✨ **Full feature support** - Works with Claude Code, Cursor, Cline, and more
* 🇪🇺 **EU-hosted infrastructure** with zero data retention

***

## Quick Start

1. **Sign up** at [tensorx.ai](https://tensorx.ai) and get your API key
2. **Choose your integration** - Claude Code, Cursor, or Cline
3. **Configure** - Point your tool to TensorX's API endpoint
4. **Start building** - Use powerful models for coding, reasoning, and more

***

## Get Started

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>🚀 Claude Code CLI</strong></td><td>Use TensorX with Claude Code in terminal</td><td><a href="/pages/1jslHbxDIby9lXImnRzH">/pages/1jslHbxDIby9lXImnRzH</a></td></tr><tr><td><strong>💻 Claude Code VS Code</strong></td><td>Claude Code extension in VS Code</td><td><a href="/pages/lWeBl8VuqGdTZWQzTDsL">/pages/lWeBl8VuqGdTZWQzTDsL</a></td></tr><tr><td><strong>⚡ Cursor</strong></td><td>Configure Cursor IDE with TensorX</td><td><a href="/pages/ANTLghfACT0GwYuweYAJ">/pages/ANTLghfACT0GwYuweYAJ</a></td></tr><tr><td><strong>🔧 Cline</strong></td><td>Set up Cline extension</td><td><a href="/pages/Rbq6bgiyNeJb0hwI5lDT">/pages/Rbq6bgiyNeJb0hwI5lDT</a></td></tr><tr><td><strong>💬 LibreChat</strong></td><td>Self-hosted ChatGPT alternative with TensorX</td><td><a href="/pages/rl148UqUvOGNcko01Sl8">/pages/rl148UqUvOGNcko01Sl8</a></td></tr><tr><td><strong>🌐 Open WebUI</strong></td><td>Feature-rich self-hosted chat interface</td><td><a href="/pages/gnU3jbVOgNiVhHmi2F1U">/pages/gnU3jbVOgNiVhHmi2F1U</a></td></tr></tbody></table>

***

## API Endpoints

| Type                    | Base URL                    |
| ----------------------- | --------------------------- |
| Claude Code / Anthropic | `https://api.tensorx.ai`    |
| OpenAI Compatible       | `https://api.tensorx.ai/v1` |

***

## Available Models

| Model             | Model ID               | Best For                        |
| ----------------- | ---------------------- | ------------------------------- |
| **GLM-5.1** ⭐     | `z-ai/glm-5.1`         | Coding, reasoning, general use  |
| **MiniMax-M2.5**  | `minimax/minimax-m2.5` | Reasoning, functions            |
| **Kimi-K2.5**     | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| **MiniMax-M2**    | `minimax/minimax-m2`   | Coding, fast responses          |
| **DeepSeek-V3.1** | `z-ai/glm-5.2`         | General chat, reasoning         |

Browse all models and pricing at [tensorx.ai/models](https://tensorx.ai/models).

{% hint style="success" %}
**Recommended for Claude Code:** GLM-5.1 offers excellent reasoning and code generation capabilities.
{% endhint %}

***

## Need Help?

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>📝 API Examples</strong></td><td>Sample curl commands and SDK examples</td><td><a href="/pages/KkLhWHmmTV9vutnjk9g6">/pages/KkLhWHmmTV9vutnjk9g6</a></td></tr><tr><td><strong>💳 Credit &#x26; Billing</strong></td><td>Payment methods and pricing info</td><td><a href="/pages/CMeEPL59vxfHWrJAmRnh">/pages/CMeEPL59vxfHWrJAmRnh</a></td></tr><tr><td><strong>❓ Troubleshooting</strong></td><td>Common issues and solutions</td><td><a href="/pages/duJQitVA5X3BB9WAgtX8">/pages/duJQitVA5X3BB9WAgtX8</a></td></tr><tr><td><strong>💬 Contact Support</strong></td><td>Get in touch with our team</td><td><a href="/pages/lbZPxIyNLptb3xB9sQUf">/pages/lbZPxIyNLptb3xB9sQUf</a></td></tr></tbody></table>


# Quickstart

Get from signup to your first API call in under 5 minutes.

{% hint style="info" %}
**TensorX was formerly Tensorix.** Existing API endpoints, keys and links keep working and redirect automatically to their `tensorx.ai` equivalents — there is nothing you need to change.
{% endhint %}

***

## Step 1: Create Your Account

1. Go to [app.tensorx.ai/register](https://app.tensorx.ai/register)
2. Enter your email and password
3. Check your inbox for a verification email
4. Click the verification link

***

## Step 2: Generate an API Key

1. Go to your [Dashboard](https://app.tensorx.ai/dashboard)
2. Navigate to **API Keys**
3. Click **Generate New Key**
4. Enter a name (e.g., "My First Key")
5. Click **Create**

{% hint style="warning" %}
**Copy your key immediately!** The full API key is only shown once. Store it somewhere safe.
{% endhint %}

***

## Step 3: Make Your First API Call

Test that everything works with a simple curl command:

```bash
curl https://api.tensorx.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"
```

You should see a JSON list of available models. 🎉

***

## Step 4: Chat with a Model

Now let's have a conversation:

{% tabs %}
{% tab title="curl" %}

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [
      {"role": "user", "content": "Hello! What can you help me with?"}
    ]
  }'
```

{% endtab %}

{% tab title="Python" %}

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[
        {"role": "user", "content": "Hello! What can you help me with?"}
    ]
)

print(response.choices[0].message.content)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.tensorx.ai/v1'
});

const response = await client.chat.completions.create({
  model: 'z-ai/glm-5.2',
  messages: [
    { role: 'user', content: 'Hello! What can you help me with?' }
  ]
});

console.log(response.choices[0].message.content);
```

{% endtab %}
{% endtabs %}

***

## Step 5: Check Your Usage

1. Go to [Dashboard → Usage](https://app.tensorx.ai/dashboard/usage)
2. See your request history with timestamps, models, tokens, and costs
3. Export to CSV if needed

***

## That's It! ✅

You're now ready to build with TensorX. Here's what to explore next:

| Next Step                    | Link                                                |
| ---------------------------- | --------------------------------------------------- |
| Browse available models      | [Models](/api-reference/models)                     |
| Learn about chat completions | [Chat API](/api-reference/chat-completions)         |
| Add function calling         | [Function Calling](/api-reference/function-calling) |
| Set up streaming             | [Streaming](/api-reference/streaming)               |
| Connect your favorite tool   | [Integrations](/#integrations)                      |

***

## Already Using OpenAI?

TensorX is a **drop-in replacement**. Just change two things:

```python
# Before (OpenAI)
client = OpenAI(api_key="sk-...")

# After (TensorX)
client = OpenAI(
    api_key="YOUR_TENSORX_KEY",
    base_url="https://api.tensorx.ai/v1"
)
```

That's it! All your existing code works unchanged.

***

## Common Issues

| Problem                | Solution                                                                         |
| ---------------------- | -------------------------------------------------------------------------------- |
| "Insufficient balance" | Add credits to your account in the [Dashboard](https://app.tensorx.ai/dashboard) |
| "401 Unauthorized"     | Check your API key is correct and complete                                       |
| "404 Not Found"        | Base URL must include `/v1`: `https://api.tensorx.ai/v1`                         |
| Key not working        | Make sure you copied the full key including `sk-` prefix                         |

***

## Need Help?

* 📧 **Email**: <support@tensorx.ai>
* 📚 **Docs**: [docs.tensorx.ai](https://docs.tensorx.ai)


# Overview

Complete API documentation for integrating TensorX into your applications.

***

## Introduction

The TensorX API provides OpenAI-compatible endpoints for accessing leading open-source and proprietary AI models. Our REST API supports both streaming and non-streaming responses, making it easy to integrate with existing applications.

{% hint style="success" %}
**OpenAI Compatible** - If you're already using OpenAI's API, simply change your base URL to `https://api.tensorx.ai/v1` and update your API key.
{% endhint %}

***

## Base URL

```
https://api.tensorx.ai/v1
```

***

## Authentication

The TensorX API uses API keys for authentication. Get your API key from your [TensorX dashboard](https://app.tensorx.ai/dashboard).

```bash
Authorization: Bearer YOUR_API_KEY
```

{% hint style="warning" %}
**Security Best Practices**

* Never expose API keys in client-side code
* Store keys in environment variables
* Rotate keys periodically
* Never commit keys to version control
  {% endhint %}

***

## Available Endpoints

| Endpoint               | Method | Description             |
| ---------------------- | ------ | ----------------------- |
| `/v1/chat/completions` | POST   | Create chat completions |
| `/v1/models`           | GET    | List available models   |

***

## Quick Example

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TENSORX_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'
```

***

## Response Format

All API responses are returned in JSON format:

```json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "z-ai/glm-5.2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 15,
    "total_tokens": 25
  }
}
```

***

## Error Handling

The API uses standard HTTP status codes:

| Status Code | Description                               |
| ----------- | ----------------------------------------- |
| `200`       | Success                                   |
| `400`       | Bad Request - Invalid parameters          |
| `401`       | Unauthorized - Invalid or missing API key |
| `402`       | Payment Required - Insufficient credits   |
| `429`       | Rate Limited - Too many requests          |
| `500`       | Server Error - Try again later            |

Error responses include a message:

```json
{
  "error": {
    "message": "Invalid API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```

***

## Rate Limits

### Current Limits

| Resource                      | Limit     |
| ----------------------------- | --------- |
| **Requests per minute (RPM)** | 60        |
| **Tokens per minute (TPM)**   | 2,000,000 |

These limits apply **per API key**. Each key you create has its own independent rate limit.

### Checking Your Usage

Every API response includes headers showing your current rate limit status:

| Header                                   | Description                    |
| ---------------------------------------- | ------------------------------ |
| `x-ratelimit-api_key-remaining-requests` | Requests remaining this minute |
| `x-ratelimit-api_key-remaining-tokens`   | Tokens remaining this minute   |

### Need Higher Limits?

**For enterprise workloads requiring higher limits:**

📧 **Contact us**: <support@tensorx.ai>

{% hint style="info" %}
**Enterprise clients** can receive custom rate limits tailored to their workload.
{% endhint %}

***

## SDKs & Libraries

Use any OpenAI-compatible SDK with TensorX:

**Python (OpenAI SDK)**

```python
from openai import OpenAI

client = OpenAI(
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)
```

**JavaScript/Node.js**

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'your-tensorx-api-key',
  baseURL: 'https://api.tensorx.ai/v1'
});
```

***

## Next Steps

* [Chat Completions](/api-reference/chat-completions) - Create chat completions
* [Models](/api-reference/models) - View available models
* [API Examples](/api-reference/api-examples) - Code examples in multiple languages


# Chat Completions

Create a model response for the given chat conversation.

***

## Endpoint

```
POST https://api.tensorx.ai/v1/chat/completions
```

***

## Authentication

```bash
Authorization: Bearer YOUR_API_KEY
```

API key is required for all requests. Get your key from your [TensorX dashboard](https://app.tensorx.ai/dashboard).

***

## Request Body

| Parameter           | Type         | Required | Default       | Description                     |
| ------------------- | ------------ | -------- | ------------- | ------------------------------- |
| `model`             | string       | **Yes**  | -             | Model ID (e.g., `z-ai/glm-5.2`) |
| `messages`          | array        | **Yes**  | -             | Array of message objects        |
| `max_tokens`        | integer      | No       | Model default | Maximum tokens to generate      |
| `temperature`       | number       | No       | 1.0           | Sampling temperature (0-2)      |
| `top_p`             | number       | No       | 1.0           | Nucleus sampling (0-1)          |
| `top_k`             | integer      | No       | -             | Top-k sampling                  |
| `stream`            | boolean      | No       | false         | Stream partial responses        |
| `stop`              | string/array | No       | -             | Stop sequences (up to 4)        |
| `presence_penalty`  | number       | No       | 0             | Presence penalty (-2 to 2)      |
| `frequency_penalty` | number       | No       | 0             | Frequency penalty (-2 to 2)     |
| `response_format`   | object       | No       | -             | Force output format             |
| `tools`             | array        | No       | -             | Function calling tools          |

### Message Object

| Field     | Type   | Required | Description                      |
| --------- | ------ | -------- | -------------------------------- |
| `role`    | string | **Yes**  | `system`, `user`, or `assistant` |
| `content` | string | **Yes**  | Message content                  |

***

## Example Request

### cURL

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TENSORX_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"}
    ],
    "max_tokens": 1000,
    "temperature": 0.7
  }'
```

### Python

```python
from openai import OpenAI

client = OpenAI(
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"}
    ],
    max_tokens=1000,
    temperature=0.7
)

print(response.choices[0].message.content)
```

### JavaScript

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'your-tensorx-api-key',
  baseURL: 'https://api.tensorx.ai/v1'
});

const response = await client.chat.completions.create({
  model: 'z-ai/glm-5.2',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is the capital of France?' }
  ],
  max_tokens: 1000,
  temperature: 0.7
});

console.log(response.choices[0].message.content);
```

***

## Response

### Success (200)

```json
{
  "id": "chatcmpl-abc123xyz",
  "object": "chat.completion",
  "created": 1706745600,
  "model": "z-ai/glm-5.2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 8,
    "total_tokens": 33
  }
}
```

### Response Fields

| Field                     | Type    | Description                                             |
| ------------------------- | ------- | ------------------------------------------------------- |
| `id`                      | string  | Unique response identifier                              |
| `object`                  | string  | Always `chat.completion`                                |
| `created`                 | integer | Unix timestamp                                          |
| `model`                   | string  | Model used for generation                               |
| `choices`                 | array   | Generated completions                                   |
| `choices[].message`       | object  | Assistant's response message                            |
| `choices[].finish_reason` | string  | Why generation stopped (`stop`, `length`, `tool_calls`) |
| `usage`                   | object  | Token usage statistics                                  |

***

## Streaming

Enable streaming for real-time responses:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TENSORX_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [{"role": "user", "content": "Tell me a story"}],
    "stream": true
  }'
```

Streaming responses are sent as Server-Sent Events (SSE):

```
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","choices":[{"delta":{"content":"Once"}}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","choices":[{"delta":{"content":" upon"}}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","choices":[{"delta":{"content":" a"}}]}

data: [DONE]
```

### Python Streaming

```python
from openai import OpenAI

client = OpenAI(
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

stream = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
```

***

## JSON Mode

Force the model to output valid JSON:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TENSORX_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [
      {"role": "user", "content": "List 3 countries and their capitals as JSON"}
    ],
    "response_format": {"type": "json_object"}
  }'
```

{% hint style="info" %}
When using JSON mode, include "JSON" in your prompt for best results.
{% endhint %}

***

## Reasoning

Several models expose a separate reasoning (thinking) step, returned in `reasoning_content` on the message. Controls differ by model family. See [Reasoning](/api-reference/reasoning) for the full per-model reference.

***

## Function Calling

Use tools for function calling:

```python
from openai import OpenAI

client = OpenAI(
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather in a location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "City name"
                    }
                },
                "required": ["location"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools
)
```

***

## Error Responses

### 401 Unauthorized

```json
{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```

### 402 Insufficient Credits

```json
{
  "error": {
    "message": "Insufficient credits",
    "type": "payment_error",
    "code": "insufficient_credits"
  }
}
```

### 429 Rate Limited

```json
{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}
```

***

## Best Practices

1. **Use streaming** for long responses to improve user experience
2. **Set appropriate max\_tokens** to control costs and response length
3. **Use lower temperature** (0.1-0.3) for factual tasks, higher (0.7-1.0) for creative tasks
4. **Include system prompts** to guide model behavior
5. **Handle errors gracefully** with retry logic for transient failures

***

## See Also

* [Models](/api-reference/models) - Available models
* [API Examples](/api-reference/api-examples) - More code examples
* [Pricing](https://tensorx.ai/pricing/) - Model pricing


# Reasoning

Several models expose a separate reasoning (thinking) step. When it runs, the response carries the reasoning in `reasoning_content` on the message and a `reasoning_tokens` count under `usage`, alongside the normal `content`.

The control differs by model family, so the table below is the quick reference. The sections that follow show each family in full.

| Model family             | Reasoning by default | How to turn on / off                                      | Depth control                                              |
| ------------------------ | -------------------- | --------------------------------------------------------- | ---------------------------------------------------------- |
| GLM 5.2                  | On                   | `chat_template_kwargs: {"enable_thinking": true / false}` | `reasoning_effort: "high"` or `"max"`                      |
| GLM 5.1, GLM 5-Turbo     | On                   | `chat_template_kwargs: {"enable_thinking": true / false}` | No effort levels                                           |
| DeepSeek V4 (Flash, Pro) | Off                  | `chat_template_kwargs: {"thinking": true}`                | `reasoning_effort: "high"` or `"max"`                      |
| MiniMax M3               | On (adaptive)        | `chat_template_kwargs: {"thinking_mode": "disabled"}`     | Modes only, no effort levels                               |
| Kimi K2.6, K2.7          | On (always)          | Not toggleable                                            | None                                                       |
| Qwen 3.8                 | On (always)          | Not toggleable                                            | `reasoning_effort: "xhigh"` (default), `"medium"`, `"low"` |

DeepSeek V4 ships with reasoning **off by default on TensorX** so the standard request is fast and cheap. Turn it on per request with `chat_template_kwargs: {"thinking": true}`.

{% hint style="info" %}
The key name is per family: GLM uses `enable_thinking`, DeepSeek V4 uses `thinking`, and MiniMax M3 uses `thinking_mode`. Sending the wrong key is silently ignored, which looks like the parameter "does nothing".
{% endhint %}

## GLM (5.2, 5.1, 5-Turbo)

GLM models think **by default**. Turn thinking off with `enable_thinking: false` inside `chat_template_kwargs`:

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

# Thinking off (direct answer, no reasoning_content)
response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "What is 15% of 240?"}],
    extra_body={"chat_template_kwargs": {"enable_thinking": False}}
)
```

On **GLM 5.2**, `reasoning_effort` has two effective levels, `"high"` and `"max"`. It is passed at the top level (OpenAI-standard):

```python
response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
    reasoning_effort="high"
)
```

`"high"` gives shorter reasoning, `"max"` gives the deepest. `"low"` and `"medium"` are accepted but map to `"high"`. To skip reasoning entirely, use `reasoning_effort: "none"` or `enable_thinking: false`. GLM 5.1 and GLM 5-Turbo support on/off but not effort levels.

## DeepSeek V4 (Flash, Pro)

DeepSeek V4 models default to **non-thinking** mode. Enable reasoning with `thinking: true` inside `chat_template_kwargs`:

{% hint style="warning" %}
**Moving from DeepSeek V4 to Qwen 3.8?** The `chat_template_kwargs: {"thinking": false}` key shown here is **accepted but ignored** on Qwen 3.8. The request returns 200, reasoning still runs, and you are still billed for it. Qwen 3.8 cannot have reasoning disabled.
{% endhint %}

```python
response = client.chat.completions.create(
    model="deepseek/deepseek-v4-pro",
    messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
    extra_body={"chat_template_kwargs": {"thinking": True}}
)

print(response.choices[0].message.reasoning_content)
print(response.choices[0].message.content)
```

Once thinking is on, control the depth with `reasoning_effort`, passed at the top level. There are two effective levels, `"high"` and `"max"`:

```python
response = client.chat.completions.create(
    model="deepseek/deepseek-v4-pro",
    messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
    extra_body={"chat_template_kwargs": {"thinking": True}},
    reasoning_effort="max"
)
```

`"high"` is the standard depth, `"max"` reasons the longest. `"low"` and `"medium"` are accepted but map to `"high"`. `reasoning_effort` has no effect unless `thinking: true` is also set.

## MiniMax M3

MiniMax M3 has three reasoning modes, set with `thinking_mode` inside `chat_template_kwargs`:

* `"enabled"`: always reason.
* `"adaptive"`: the model decides when to reason. This is the default.
* `"disabled"`: no reasoning, direct answer.

```python
# Reasoning off
response = client.chat.completions.create(
    model="minimax/minimax-m3",
    messages=[{"role": "user", "content": "What is 15% of 240?"}],
    extra_body={"chat_template_kwargs": {"thinking_mode": "disabled"}}
)
```

M3 uses `thinking_mode`, not `thinking` or `enable_thinking`, and the value is one of the three modes above. It does not take graded `reasoning_effort` levels, so use the modes to control reasoning.

## Kimi (K2.6, K2.7)

Kimi models reason **by default and cannot be toggled off**. There is no `enable_thinking` or `thinking` flag to set. `reasoning_content` is always populated.

## Qwen 3.8

Qwen 3.8 thinks on **every** request. Unlike the other families, reasoning **cannot be switched off**. The model rejects any attempt:

* `chat_template_kwargs: {"enable_thinking": false}` returns `400 Disabling thinking is not supported.`
* `reasoning_effort: "none"` returns the same error.

Depth is controlled with the standard top-level `reasoning_effort`, but the accepted values differ from other models on the platform:

| Value      | Effect                                                                                                        |
| ---------- | ------------------------------------------------------------------------------------------------------------- |
| `"xhigh"`  | **Default.** Asks the model to validate assumptions and weigh alternatives. Most thorough, most output tokens |
| `"medium"` | No steering. The model's natural reasoning, and the cheapest of the three                                     |
| `"low"`    | Asks the model to keep thinking brief and reach the conclusion directly                                       |

{% hint style="warning" %}
**`reasoning_effort: "high"` returns a 400 on Qwen 3.8.** Use `"xhigh"`. `"high"` is the OpenAI-standard value and works on GLM 5.2, so ported code often sends it by default.
{% endhint %}

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

response = client.chat.completions.create(
    model="qwen/qwen3.8-2.4t-a95b",
    messages=[{"role": "user", "content": "A bat and ball cost 1.10 in total. The bat costs 1.00 more than the ball. How much is the ball?"}],
    reasoning_effort="low"
)

print(response.choices[0].message.reasoning_content)  # the thinking
print(response.choices[0].message.content)            # the answer
print(response.usage.reasoning_tokens)                # billed as output
```

Reasoning arrives in `reasoning_content`, with no `<think>` tags left in `content`. When streaming, reasoning arrives as `delta.reasoning_content` deltas **before** the content deltas begin.

**Reasoning tokens are billed as output tokens.** They are counted inside `completion_tokens` and reported separately as `usage.reasoning_tokens`, so you can always see how much of a response was thinking.


# Function Calling

Let AI models call your functions to take actions and retrieve information.

***

## Overview

Function calling (also called "tools") allows models to:

* Request specific data from your systems
* Trigger actions in your application
* Access real-time information
* Perform calculations

The model doesn't execute functions directly—it returns a structured request for your code to handle.

***

## Supported Models

| Model                       | Function Calling |
| --------------------------- | ---------------- |
| `z-ai/glm-5.1`              | ✅                |
| `minimax/minimax-m2.5`      | ✅                |
| `moonshotai/kimi-k2.5`      | ✅                |
| `z-ai/glm-5.2`              | ✅                |
| `deepseek/deepseek-r1-0528` | ✅                |
| `minimax/minimax-m2`        | ✅                |
| `qwen/qwen3-235b-a22b-2507` | ✅                |
| `moonshotai/kimi-k3`        | ✅                |

***

## Basic Example

Here's a weather function the model can call:

{% tabs %}
{% tab title="Python" %}

```python
from openai import OpenAI
import json

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

# Define your tools
tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "City name, e.g. London, UK"
                    },
                    "unit": {
                        "type": "string",
                        "enum": ["celsius", "fahrenheit"],
                        "description": "Temperature unit"
                    }
                },
                "required": ["location"]
            }
        }
    }
]

# Make the request
response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[
        {"role": "user", "content": "What's the weather in Tokyo?"}
    ],
    tools=tools
)

# Check if model wants to call a function
message = response.choices[0].message
if message.tool_calls:
    tool_call = message.tool_calls[0]
    print(f"Function: {tool_call.function.name}")
    print(f"Arguments: {tool_call.function.arguments}")
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.tensorx.ai/v1'
});

const tools = [
  {
    type: 'function',
    function: {
      name: 'get_weather',
      description: 'Get the current weather for a location',
      parameters: {
        type: 'object',
        properties: {
          location: {
            type: 'string',
            description: 'City name, e.g. London, UK'
          },
          unit: {
            type: 'string',
            enum: ['celsius', 'fahrenheit'],
            description: 'Temperature unit'
          }
        },
        required: ['location']
      }
    }
  }
];

const response = await client.chat.completions.create({
  model: 'z-ai/glm-5.2',
  messages: [
    { role: 'user', content: "What's the weather in Tokyo?" }
  ],
  tools
});

const message = response.choices[0].message;
if (message.tool_calls) {
  const toolCall = message.tool_calls[0];
  console.log(`Function: ${toolCall.function.name}`);
  console.log(`Arguments: ${toolCall.function.arguments}`);
}
```

{% endtab %}

{% tab title="curl" %}

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [
      {"role": "user", "content": "What'\''s the weather in Tokyo?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get the current weather for a location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "City name, e.g. London, UK"
              }
            },
            "required": ["location"]
          }
        }
      }
    ]
  }'
```

{% endtab %}
{% endtabs %}

***

## Response Format

When the model decides to call a function:

```json
{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_abc123",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"location\":\"Tokyo, Japan\",\"unit\":\"celsius\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ]
}
```

Key fields:

* `tool_calls` - Array of functions the model wants to call
* `id` - Unique ID for this tool call (use when sending results back)
* `arguments` - JSON string of function parameters
* `finish_reason: "tool_calls"` - Indicates model is waiting for results

***

## Complete Flow

A full function calling conversation:

```python
import json

# Step 1: Send user message with tools
response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[
        {"role": "user", "content": "What's the weather in Paris?"}
    ],
    tools=tools
)

message = response.choices[0].message

# Step 2: Check if model wants to call functions
if message.tool_calls:
    # Step 3: Execute the function(s)
    tool_call = message.tool_calls[0]
    function_name = tool_call.function.name
    arguments = json.loads(tool_call.function.arguments)
    
    # Your actual function implementation
    if function_name == "get_weather":
        result = get_weather(arguments["location"])  # Your code
    
    # Step 4: Send the result back
    response = client.chat.completions.create(
        model="z-ai/glm-5.2",
        messages=[
            {"role": "user", "content": "What's the weather in Paris?"},
            message,  # Include the assistant's tool_calls message
            {
                "role": "tool",
                "tool_call_id": tool_call.id,
                "content": json.dumps(result)
            }
        ],
        tools=tools
    )
    
    # Step 5: Get the final response
    print(response.choices[0].message.content)
```

***

## Tool Choice Options

Control when the model uses functions:

```python
# Let model decide (default)
tool_choice="auto"

# Never call functions
tool_choice="none"

# Must call a function
tool_choice="required"

# Force a specific function
tool_choice={"type": "function", "function": {"name": "get_weather"}}
```

***

## Parallel Tool Calls

Models can request multiple functions at once:

```json
{
  "tool_calls": [
    {"id": "call_1", "function": {"name": "get_weather", "arguments": "{\"location\":\"Paris\"}"}},
    {"id": "call_2", "function": {"name": "get_weather", "arguments": "{\"location\":\"London\"}"}}
  ]
}
```

Handle all calls and return all results:

```python
messages = [original_user_message, assistant_message]

for tool_call in message.tool_calls:
    result = execute_function(tool_call.function.name, tool_call.function.arguments)
    messages.append({
        "role": "tool",
        "tool_call_id": tool_call.id,
        "content": json.dumps(result)
    })

response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=messages,
    tools=tools
)
```

***

## Common Tool Examples

### Web Search

```python
{
    "type": "function",
    "function": {
        "name": "web_search",
        "description": "Search the web for current information",
        "parameters": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The search query"
                }
            },
            "required": ["query"]
        }
    }
}
```

### Calculator

```python
{
    "type": "function",
    "function": {
        "name": "calculate",
        "description": "Perform mathematical calculations",
        "parameters": {
            "type": "object",
            "properties": {
                "expression": {
                    "type": "string",
                    "description": "Math expression, e.g. '2+2', 'sqrt(16)', '15% of 200'"
                }
            },
            "required": ["expression"]
        }
    }
}
```

### Database Query

```python
{
    "type": "function",
    "function": {
        "name": "query_database",
        "description": "Query the product database",
        "parameters": {
            "type": "object",
            "properties": {
                "table": {
                    "type": "string",
                    "enum": ["products", "orders", "customers"]
                },
                "filters": {
                    "type": "object",
                    "description": "Key-value pairs to filter by"
                },
                "limit": {
                    "type": "integer",
                    "description": "Maximum results to return"
                }
            },
            "required": ["table"]
        }
    }
}
```

***

## Best Practices

### Writing Good Descriptions

The `description` field is crucial—it tells the model when to use the function:

```python
# ❌ Bad: Too vague
"description": "Gets data"

# ✅ Good: Clear and specific
"description": "Get the current weather conditions including temperature, humidity, and forecast for a specific city"
```

### Parameter Descriptions

Help the model provide correct arguments:

```python
"location": {
    "type": "string",
    "description": "City and country, e.g. 'Paris, France' or 'New York, USA'"
}
```

### Error Handling

Return errors as tool results so the model can respond appropriately:

```python
try:
    result = get_weather(location)
except Exception as e:
    result = {"error": str(e)}

# The model will see the error and can tell the user
```

***

## See Also

* [Chat Completions](/api-reference/chat-completions) - Full API reference
* [Streaming](/api-reference/streaming) - Stream function call responses
* [Models](/api-reference/models) - Models that support function calling


# Streaming

Get responses in real-time as they're generated.

***

## Overview

Streaming delivers the model's response piece by piece instead of waiting for the complete answer. This provides:

* **Better user experience** - Show progress immediately
* **Lower perceived latency** - Users see content within milliseconds
* **Efficient for long responses** - Don't wait for entire generation

***

## Basic Usage

Add `stream: true` to your request:

{% tabs %}
{% tab title="Python" %}

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

stream = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "Write a haiku about coding"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.tensorx.ai/v1'
});

const stream = await client.chat.completions.create({
  model: 'z-ai/glm-5.2',
  messages: [{ role: 'user', content: 'Write a haiku about coding' }],
  stream: true
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) {
    process.stdout.write(content);
  }
}
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -N https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [{"role": "user", "content": "Write a haiku about coding"}],
    "stream": true
  }'
```

{% endtab %}
{% endtabs %}

***

## Getting Token Usage

To track token usage with streaming, add `stream_options`:

```python
stream = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
    stream_options={"include_usage": True}
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
    
    # Usage appears in the final chunk
    if chunk.usage:
        print(f"\n\nTokens: {chunk.usage.total_tokens}")
```

{% hint style="info" %}
Token usage is included in the final chunk when `include_usage: true`.
{% endhint %}

***

## Server-Sent Events Format

Under the hood, streaming uses Server-Sent Events (SSE):

```
data: {"id":"chatcmpl-xyz","choices":[{"delta":{"role":"assistant"},"index":0}]}

data: {"id":"chatcmpl-xyz","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: {"id":"chatcmpl-xyz","choices":[{"delta":{"content":" there"},"index":0}]}

data: {"id":"chatcmpl-xyz","choices":[{"delta":{},"index":0,"finish_reason":"stop"}],"usage":{"prompt_tokens":10,"completion_tokens":5,"total_tokens":15}}

data: [DONE]
```

Each line:

* Starts with `data:`
* Contains a JSON chunk or `[DONE]`
* `delta` contains the new content piece
* `finish_reason` appears in the final content chunk

***

## Raw HTTP Streaming

If you're not using an SDK:

```python
import requests
import json

response = requests.post(
    'https://api.tensorx.ai/v1/chat/completions',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'model': 'z-ai/glm-5.2',
        'messages': [{'role': 'user', 'content': 'Count to 5'}],
        'stream': True
    },
    stream=True  # Important!
)

for line in response.iter_lines():
    if line:
        line = line.decode('utf-8')
        if line.startswith('data: '):
            data = line[6:]  # Remove 'data: ' prefix
            if data == '[DONE]':
                break
            chunk = json.loads(data)
            content = chunk['choices'][0]['delta'].get('content', '')
            if content:
                print(content, end='', flush=True)
```

***

## Accumulating the Full Response

Sometimes you need both streaming display AND the complete text:

```python
full_response = ""

stream = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "Explain recursion"}],
    stream=True
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        full_response += content
        print(content, end="", flush=True)

# Now you have the complete response
print(f"\n\nTotal length: {len(full_response)} characters")
```

***

## When to Use Streaming

### ✅ Use Streaming For

| Use Case                    | Why                              |
| --------------------------- | -------------------------------- |
| Chat interfaces             | Users see responses immediately  |
| Long-form content           | Articles, stories, documentation |
| Code generation             | See code as it's written         |
| Real-time applications      | Live transcription, assistants   |
| Large outputs (>500 tokens) | Better user experience           |

### ❌ Don't Use Streaming For

| Use Case                      | Why                            |
| ----------------------------- | ------------------------------ |
| Batch processing              | Adds complexity, no UX benefit |
| Background jobs               | No one watching                |
| JSON mode / structured output | Need complete valid JSON       |
| Function calling              | Wait for complete tool\_calls  |
| Short responses (<100 tokens) | Negligible difference          |
| Validation required           | Need full response first       |

***

## Handling Finish Reasons

Check `finish_reason` in the final chunk:

```python
for chunk in stream:
    if chunk.choices[0].finish_reason:
        reason = chunk.choices[0].finish_reason
        
        if reason == "stop":
            print("\n✓ Complete")
        elif reason == "length":
            print("\n⚠️ Truncated (max_tokens reached)")
        elif reason == "content_filter":
            print("\n⚠️ Content filtered")
        elif reason == "tool_calls":
            print("\n→ Function call requested")
```

***

## Error Handling

Streams can fail mid-response. Always handle errors:

```python
try:
    stream = client.chat.completions.create(
        model="z-ai/glm-5.2",
        messages=[{"role": "user", "content": "Hello"}],
        stream=True
    )
    
    for chunk in stream:
        if chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="")
            
except Exception as e:
    print(f"\n\nStream error: {e}")
    # Optionally retry without streaming
```

***

## Streaming with Function Calling

When using tools, the model may return tool calls. These come all at once (not streamed character by character):

```python
stream = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "What's the weather?"}],
    tools=tools,
    stream=True
)

tool_calls = []

for chunk in stream:
    delta = chunk.choices[0].delta
    
    # Accumulate tool calls
    if delta.tool_calls:
        for tc in delta.tool_calls:
            # Tool calls stream in pieces too
            if tc.index >= len(tool_calls):
                tool_calls.append({"id": "", "function": {"name": "", "arguments": ""}})
            if tc.id:
                tool_calls[tc.index]["id"] = tc.id
            if tc.function:
                if tc.function.name:
                    tool_calls[tc.index]["function"]["name"] = tc.function.name
                if tc.function.arguments:
                    tool_calls[tc.index]["function"]["arguments"] += tc.function.arguments
```

{% hint style="info" %}
For simpler code, consider using non-streaming requests when function calling is involved.
{% endhint %}

***

## See Also

* [Chat Completions](/api-reference/chat-completions) - Full API reference
* [Function Calling](/api-reference/function-calling) - Using tools
* [Rate Limits](/api-reference/rate-limits) - Request limits


# Audio API

TensorX provides OpenAI-compatible audio endpoints for both Text-to-Speech (TTS) and Speech-to-Text (STT) transcription.

## Available Models

| Model                             | Type | Description                            |
| --------------------------------- | ---- | -------------------------------------- |
| `chatterbox-turbo`                | TTS  | High-quality text-to-speech generation |
| `Systran/faster-whisper-large-v3` | STT  | Fast, accurate speech transcription    |

## Text-to-Speech (TTS)

Convert text into natural-sounding audio using the `chatterbox-turbo` model.

### Endpoint

```
POST https://api.tensorx.ai/v1/audio/speech
```

### Basic Usage

```bash
curl https://api.tensorx.ai/v1/audio/speech \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "chatterbox-turbo",
    "input": "Hello! Welcome to TensorX.",
    "voice": "Emily.wav"
  }' \
  --output speech.mp3
```

### Parameters

| Parameter         | Type   | Required | Description                                                                                                                                         |
| ----------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`           | string | Yes      | Model ID: `chatterbox-turbo`                                                                                                                        |
| `input`           | string | Yes      | Text to convert to speech. For very long inputs, split into smaller chunks and concatenate the resulting audio.                                     |
| `voice`           | string | Yes      | Voice ID, using the filename of one of the predefined voices below (e.g. `Emily.wav`). OpenAI-style names like `alloy` or `nova` are not supported. |
| `response_format` | string | No       | Audio format: `mp3`, `wav`, `opus` (default: `mp3`)                                                                                                 |
| `speed`           | number | No       | Playback speed multiplier (default: 1.0). Values around 0.5 to 2.0 give the most natural results.                                                   |

### Available Voices

`chatterbox-turbo` ships with 28 predefined English voices. Pass the filename (including the `.wav` suffix) as the `voice` parameter:

|               |                |                 |               |
| ------------- | -------------- | --------------- | ------------- |
| `Abigail.wav` | `Adrian.wav`   | `Alexander.wav` | `Alice.wav`   |
| `Austin.wav`  | `Axel.wav`     | `Connor.wav`    | `Cora.wav`    |
| `Elena.wav`   | `Eli.wav`      | `Emily.wav`     | `Everett.wav` |
| `Gabriel.wav` | `Gianna.wav`   | `Henry.wav`     | `Ian.wav`     |
| `Jade.wav`    | `Jeremiah.wav` | `Jordan.wav`    | `Julian.wav`  |
| `Layla.wav`   | `Leonardo.wav` | `Michael.wav`   | `Miles.wav`   |
| `Olivia.wav`  | `Ryan.wav`     | `Taylor.wav`    | `Thomas.wav`  |

The TTS engine is a hosted instance of the open-source [Chatterbox-TTS-Server](https://github.com/devnen/Chatterbox-TTS-Server) project, which is in turn built on [Resemble AI's Chatterbox](https://github.com/resemble-ai/chatterbox) model. See the upstream documentation for details on the voices, voice characteristics, and how voice cloning works.

### Python Example

```python
import requests

response = requests.post(
    "https://api.tensorx.ai/v1/audio/speech",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "model": "chatterbox-turbo",
        "input": "Welcome to TensorX! This is a test of our text-to-speech API.",
        "voice": "Emily.wav"
    }
)

# Save audio file
with open("output.mp3", "wb") as f:
    f.write(response.content)

print(f"Audio saved: {len(response.content)} bytes")
```

### JavaScript/Node.js Example

```javascript
const fs = require('fs');

async function textToSpeech(text) {
  const response = await fetch('https://api.tensorx.ai/v1/audio/speech', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'chatterbox-turbo',
      input: text,
      voice: 'Emily.wav'
    })
  });

  const buffer = await response.arrayBuffer();
  fs.writeFileSync('output.mp3', Buffer.from(buffer));
  console.log('Audio saved!');
}

textToSpeech('Hello from TensorX!');
```

### Pricing

**TTS Cost**: $0.000005 per character

| Text Length       | Cost    |
| ----------------- | ------- |
| 100 characters    | $0.0005 |
| 1,000 characters  | $0.005  |
| 10,000 characters | $0.05   |

***

## Speech-to-Text (STT)

Transcribe audio files to text using the `Systran/faster-whisper-large-v3` model.

### Endpoint

```
POST https://api.tensorx.ai/v1/audio/transcriptions
```

### Basic Usage

```bash
curl https://api.tensorx.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F file="@audio.mp3" \
  -F model="Systran/faster-whisper-large-v3"
```

### Parameters

| Parameter                 | Type   | Required | Description                                                                   |
| ------------------------- | ------ | -------- | ----------------------------------------------------------------------------- |
| `file`                    | file   | Yes      | Audio file to transcribe (mp3, mp4, mpeg, mpga, m4a, wav, webm)               |
| `model`                   | string | Yes      | Model ID: `Systran/faster-whisper-large-v3`                                   |
| `language`                | string | No       | Language code (e.g., `en`, `es`, `fr`). Auto-detected if not specified        |
| `response_format`         | string | No       | Output format: `json`, `text`, `srt`, `vtt`, `verbose_json` (default: `json`) |
| `timestamp_granularities` | array  | No       | `["word"]` or `["segment"]` for timestamps                                    |

### Response

```json
{
  "text": "Hello, this is a test of the TensorX Audio Gateway.",
  "language": "en",
  "duration": 5.44,
  "segments": [
    {
      "start": 0.0,
      "end": 2.5,
      "text": "Hello, this is a test"
    },
    {
      "start": 2.5,
      "end": 5.44,
      "text": "of the TensorX Audio Gateway."
    }
  ]
}
```

### Python Example

```python
import requests

# Transcribe audio file
with open("audio.mp3", "rb") as audio_file:
    response = requests.post(
        "https://api.tensorx.ai/v1/audio/transcriptions",
        headers={
            "Authorization": "Bearer YOUR_API_KEY"
        },
        files={
            "file": audio_file
        },
        data={
            "model": "Systran/faster-whisper-large-v3"
        }
    )

result = response.json()
print(f"Transcription: {result['text']}")
print(f"Language: {result.get('language', 'auto')}")
print(f"Duration: {result.get('duration', 'N/A')} seconds")
```

### JavaScript/Node.js Example

```javascript
const fs = require('fs');
const FormData = require('form-data');

async function transcribeAudio(filePath) {
  const form = new FormData();
  form.append('file', fs.createReadStream(filePath));
  form.append('model', 'Systran/faster-whisper-large-v3');

  const response = await fetch('https://api.tensorx.ai/v1/audio/transcriptions', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: form
  });

  const result = await response.json();
  console.log('Transcription:', result.text);
  return result;
}

transcribeAudio('audio.mp3');
```

### Get Timestamps

Request word or segment-level timestamps:

```bash
curl https://api.tensorx.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F file="@audio.mp3" \
  -F model="Systran/faster-whisper-large-v3" \
  -F response_format="verbose_json" \
  -F 'timestamp_granularities[]=segment'
```

### Pricing

**STT Cost**: $0.0000667 per second of audio

| Audio Duration | Cost   |
| -------------- | ------ |
| 1 minute       | $0.004 |
| 10 minutes     | $0.04  |
| 1 hour         | $0.24  |

***

## Supported Audio Formats

Both TTS and STT support the following audio formats:

| Format | Extension        | Notes                          |
| ------ | ---------------- | ------------------------------ |
| MP3    | `.mp3`           | Most common, good compression  |
| WAV    | `.wav`           | Uncompressed, highest quality  |
| M4A    | `.m4a`           | Apple audio format             |
| WEBM   | `.webm`          | Web-optimized                  |
| MPEG   | `.mpeg`, `.mpga` | Legacy format                  |
| MP4    | `.mp4`           | Video format (audio extracted) |
| OGG    | `.ogg`           | Open source format             |

### File Size Limits

* Maximum file size: **25 MB**
* For larger files, split them into smaller segments

***

## Use Cases

### Voice Assistants

```python
# Complete voice assistant flow
import requests

def voice_assistant(audio_input_path):
    # 1. Transcribe user's speech
    with open(audio_input_path, "rb") as f:
        transcription = requests.post(
            "https://api.tensorx.ai/v1/audio/transcriptions",
            headers={"Authorization": "Bearer YOUR_API_KEY"},
            files={"file": f},
            data={"model": "Systran/faster-whisper-large-v3"}
        ).json()
    
    user_text = transcription["text"]
    print(f"User said: {user_text}")
    
    # 2. Get AI response (using chat completions)
    # Use any chat model from /v1/models. `z-ai/glm-5.2`
    # is a fast, low-cost default; swap in another model if you prefer.
    ai_response = requests.post(
        "https://api.tensorx.ai/v1/chat/completions",
        headers={
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json"
        },
        json={
            "model": "z-ai/glm-5.2",
            "messages": [{"role": "user", "content": user_text}]
        }
    ).json()
    
    assistant_text = ai_response["choices"][0]["message"]["content"]
    print(f"Assistant: {assistant_text}")
    
    # 3. Convert response to speech
    audio = requests.post(
        "https://api.tensorx.ai/v1/audio/speech",
        headers={
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json"
        },
        json={
            "model": "chatterbox-turbo",
            "input": assistant_text,
            "voice": "Emily.wav"
        }
    )
    
    with open("response.mp3", "wb") as f:
        f.write(audio.content)
    
    return "response.mp3"
```

### Podcast Transcription

```python
def transcribe_podcast(file_path):
    with open(file_path, "rb") as f:
        response = requests.post(
            "https://api.tensorx.ai/v1/audio/transcriptions",
            headers={"Authorization": "Bearer YOUR_API_KEY"},
            files={"file": f},
            data={
                "model": "Systran/faster-whisper-large-v3",
                "response_format": "srt"  # Get SRT subtitles
            }
        )
    
    # Save as subtitle file
    with open("podcast.srt", "w") as f:
        f.write(response.text)
    
    return "podcast.srt"
```

### Content Narration

```python
def narrate_article(article_text):
    # Split long articles into chunks. There is no hard cap on `input` length,
    # but chunking on sentence boundaries gives more natural pacing and lets
    # you stream playback while later chunks are still being generated.
    max_chars = 4000
    chunks = [article_text[i:i+max_chars] for i in range(0, len(article_text), max_chars)]
    
    audio_parts = []
    for i, chunk in enumerate(chunks):
        response = requests.post(
            "https://api.tensorx.ai/v1/audio/speech",
            headers={
                "Authorization": "Bearer YOUR_API_KEY",
                "Content-Type": "application/json"
            },
            json={
                "model": "chatterbox-turbo",
                "input": chunk,
                "voice": "Emily.wav"
            }
        )
        
        filename = f"part_{i}.mp3"
        with open(filename, "wb") as f:
            f.write(response.content)
        audio_parts.append(filename)
    
    return audio_parts
```

***

## Error Handling

### Common Errors

| Error Code | Description          | Solution                              |
| ---------- | -------------------- | ------------------------------------- |
| 400        | Invalid audio format | Use supported format (mp3, wav, etc.) |
| 400        | File too large       | Split into chunks under 25MB          |
| 401        | Invalid API key      | Check your API key                    |
| 413        | Payload too large    | Reduce file size                      |
| 429        | Rate limit exceeded  | Reduce request frequency              |

### Python Error Handling

```python
import requests

def safe_transcribe(file_path):
    try:
        with open(file_path, "rb") as f:
            response = requests.post(
                "https://api.tensorx.ai/v1/audio/transcriptions",
                headers={"Authorization": "Bearer YOUR_API_KEY"},
                files={"file": f},
                data={"model": "Systran/faster-whisper-large-v3"}
            )
        
        response.raise_for_status()
        return response.json()
    
    except requests.exceptions.HTTPError as e:
        print(f"HTTP Error: {e.response.status_code}")
        print(f"Details: {e.response.text}")
        return None
    except FileNotFoundError:
        print(f"File not found: {file_path}")
        return None
```

***

## Resources

* [OpenAI Audio API Reference](https://platform.openai.com/docs/api-reference/audio)
* [TensorX API Overview](/api-reference/overview)
* [TensorX Models](/api-reference/models)


# Models

Available models on the TensorX platform.

***

## Overview

TensorX provides access to leading open-source and proprietary AI models through a unified API. All models are accessible via the same OpenAI-compatible endpoint.

{% hint style="info" %}
**Live Pricing & Full List**: Visit [tensorx.ai/models](https://tensorx.ai/models) for real-time pricing and the complete model catalog.
{% endhint %}

***

## Model Capabilities

Our Large Language Models (LLMs) support:

* **Text Generation** - Generate coherent, contextual content
* **Language Understanding** - Understand meaning and context
* **Code Generation** - Write, analyze, and debug code
* **Reasoning** - Complex problem solving and analysis
* **Function Calling** - Tool use and structured outputs
* **Vision** - Image understanding (select models)
* **Multilingual** - Support for multiple languages
* **Text-to-Speech** - Convert text to natural audio
* **Speech-to-Text** - Transcribe audio to text

***

## Available Models

TensorX hosts a broad catalogue of leading open and proprietary models (GLM, MiniMax, Moonshot Kimi, DeepSeek, Qwen, Llama) plus audio models for TTS and STT, all on the same OpenAI-compatible endpoint.

{% hint style="info" %}
**The model list and pricing change regularly.** For the current catalogue and live pricing, see [tensorx.ai/models](https://tensorx.ai/models), or call the [List Models API](#list-models-api) below to fetch the available model IDs programmatically.
{% endhint %}

See the [Model Recommendations](#model-recommendations) below for which model to pick by use case.

### Vendor names

Most model IDs match the name the vendor uses. Two do not:

* **`qwen/qwen3.8-2.4t-a95b`** is Alibaba's **Qwen3.8-Max**. 2.4T parameters, 95B active, 262,144 context. Reasoning is always on, see [Reasoning](/api-reference/reasoning).
* **`deepseek/deepseek-v4-flash-0731`** is **DeepSeek-V4 Flash**. The `-0731` suffix identifies the build we serve.

***

## Model Recommendations

| Use Case              | Recommended Models                                                                      |
| --------------------- | --------------------------------------------------------------------------------------- |
| **General Chat**      | `z-ai/glm-5.2`, `meta-llama/llama-3.3-70b-instruct`                                     |
| **Complex Reasoning** | `qwen/qwen3.8-2.4t-a95b`, `deepseek/deepseek-r1-0528`, `z-ai/glm-5.1`                   |
| **Coding**            | `z-ai/glm-5.1`, `minimax/minimax-m2`                                                    |
| **Vision Tasks**      | `moonshotai/kimi-k3`, `minimax/minimax-m3`, `moonshotai/kimi-k2.6`, `z-ai/glm-5v-turbo` |
| **Long Context**      | `moonshotai/kimi-k2.5` (262K), `meta-llama/llama-4-maverick` (1050K)                    |
| **Multilingual**      | `z-ai/glm-5.1` (Chinese/English)                                                        |
| **Text-to-Speech**    | `chatterbox-turbo`                                                                      |
| **Speech-to-Text**    | `Systran/faster-whisper-large-v3`                                                       |

***

## List Models API

Retrieve the list of available models programmatically:

```bash
curl https://api.tensorx.ai/v1/models \
  -H "Authorization: Bearer $TENSORX_API_KEY"
```

### Response

```json
{
  "object": "list",
  "data": [
    {
      "id": "z-ai/glm-5.2",
      "object": "model",
      "created": 1706745600,
      "owned_by": "deepseek"
    },
    {
      "id": "z-ai/glm-5.1",
      "object": "model",
      "created": 1706745600,
      "owned_by": "z-ai"
    }
  ]
}
```

***

## Using Models

Specify the model ID in your API request:

```python
from openai import OpenAI

client = OpenAI(
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

# Use DeepSeek for fast reasoning
response = client.chat.completions.create(
    model="z-ai/glm-5.2",
    messages=[{"role": "user", "content": "Explain quantum computing"}]
)

# Use GLM for coding
response = client.chat.completions.create(
    model="z-ai/glm-5.1",
    messages=[{"role": "user", "content": "Write a Python function to sort a list"}]
)

# Use Llama for long context
response = client.chat.completions.create(
    model="meta-llama/llama-4-maverick",
    messages=[{"role": "user", "content": "Summarize this document..."}]
)
```

***

## Pricing

Model pricing is based on token usage (input + output tokens).

{% hint style="success" %}
**View Current Pricing**: [tensorx.ai/models](https://tensorx.ai/models)

Pricing is displayed per 1M tokens for each model.
{% endhint %}

### How Pricing Works

```
Cost = (Input Tokens × Input Price) + (Output Tokens × Output Price)
```

* **Input tokens**: Text you send to the model
* **Output tokens**: Text the model generates

### Tips to Optimize Costs

1. **Choose the right model** - Use smaller models for simple tasks
2. **Set max\_tokens** - Limit output length when appropriate
3. **Use caching** - Cache responses for repeated queries
4. **Monitor usage** - Check your [dashboard](https://app.tensorx.ai/dashboard) regularly

***

## Feature Support

| Feature              | Supported Models                                                                                                                                                            |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Function Calling** | DeepSeek, GLM, Qwen, MiniMax                                                                                                                                                |
| **Reasoning**        | GLM, DeepSeek, MiniMax, Kimi                                                                                                                                                |
| **Vision**           | `moonshotai/kimi-k2.5`, `moonshotai/kimi-k2.6`, `moonshotai/kimi-k2.7-code`, `minimax/minimax-m3`, `moonshotai/kimi-k3`, `z-ai/glm-5v-turbo`, `meta-llama/llama-4-maverick` |
| **Streaming**        | All models                                                                                                                                                                  |
| **JSON Mode**        | All models                                                                                                                                                                  |
| **Text-to-Speech**   | chatterbox-turbo                                                                                                                                                            |
| **Speech-to-Text**   | Systran/faster-whisper-large-v3                                                                                                                                             |

{% hint style="info" %}
**Vision** means the model accepts image input (`image_url` content parts). Text-only models will not read images even if a request is accepted. The List Models API does not currently return per-model capability flags, so use this table for image support.
{% endhint %}

***

## See Also

* [Chat Completions](/api-reference/chat-completions) - API endpoint documentation
* [Quantisation](/api-reference/quantisation) - How models are quantised and how to check the level for any specific model
* [Audio API](/api-reference/audio) - TTS and STT documentation
* [API Examples](/api-reference/api-examples) - Code examples
* [Pricing](https://tensorx.ai/models) - Live pricing


# Embeddings

TensorX serves text embeddings through the standard OpenAI-compatible `/v1/embeddings` endpoint. One embedding model is available:

| Model                     | Output dimensions | Max input     | Pricing                                            |
| ------------------------- | ----------------- | ------------- | -------------------------------------------------- |
| `qwen/qwen3-embedding-8b` | 4096 (fixed)      | 40,960 tokens | See [tensorx.ai/models](https://tensorx.ai/models) |

## Basic usage

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

resp = client.embeddings.create(
    model="qwen/qwen3-embedding-8b",
    input="The capital of France is Paris."
)

vector = resp.data[0].embedding   # list of 4096 floats
```

Batch inputs by passing a list. Each item gets its own vector, returned in the same order:

```python
resp = client.embeddings.create(
    model="qwen/qwen3-embedding-8b",
    input=["first document", "second document", "third document"]
)
vectors = [d.embedding for d in resp.data]
```

## Input limit

The model context length is **40,960 tokens**. Requests above this are rejected; nothing is truncated for you.

For RAG or document indexing, chunk your text to well under 40,960 tokens per item before sending. Chunks of 512 to 1,024 tokens are typical for retrieval.

{% hint style="warning" %}
Every item in a batch must be non-empty. A blank or whitespace-only string fails the whole request. Filter empty strings before sending.
{% endhint %}

## The `dimensions` parameter is not supported

OpenAI's `text-embedding-3` models accept a `dimensions` parameter to shorten the output vector. Some client libraries and tools (for example Cherry Studio, and some Open WebUI setups) send it automatically.

`qwen/qwen3-embedding-8b` **does not accept `dimensions`**. Sending it fails the request. If your tool sets `dimensions` automatically, turn that option off. The model always returns the full 4096-dimensional vector.

{% hint style="info" %}
**Need smaller vectors?** Qwen3-Embedding uses Matryoshka Representation Learning, so you can shorten the vector yourself: request the full 4096-dim embedding, keep the first N values, then re-normalise (L2). Normalising *after* truncation is what preserves quality.

```python
import numpy as np

full = np.array(resp.data[0].embedding)   # 4096 dims
short = full[:512]                         # keep the first 512
short = short / np.linalg.norm(short)      # re-normalise
```

{% endhint %}

## Errors

All of the cases below return the same generic response:

```
HTTP 400
{ "error": { "message": "The request contained an invalid argument.
  Please check your request parameters and try again.",
  "type": "invalid_request_error", "code": "400" } }
```

The API does not tell you which of these caused it, so check them in order:

| Cause                                    | What to change                              |
| ---------------------------------------- | ------------------------------------------- |
| Sent a `dimensions` parameter            | Remove it; truncate client-side (see above) |
| Input over 40,960 tokens                 | Chunk the input to smaller pieces           |
| Blank or whitespace-only item in a batch | Filter empty inputs before sending          |

## See Also

* [Models](/api-reference/models) - full model catalogue
* [Rate Limits](/api-reference/rate-limits)
* [API Examples](/api-reference/api-examples)


# Quantisation

How models are quantised on TensorX, and how to check the quantisation for any specific model.

***

## Overview

Every Large Language Model on the TensorX platform is served in a **quantised** format. There is no separate "full-precision" or "non-quantised" variant - the published deployment is already quantised to the right precision for production serving on TensorX hardware.

This page explains which quantisation levels are in use, why, and how to read the value for any specific model.

{% hint style="info" %}
**TL;DR.** Almost every LLM on TensorX runs at `fp8`. The Kimi K2 family runs at native `int4`, and the `deepseek-v4-flash-backup` model runs at `fp4`. Audio models do not carry a quantisation label.
{% endhint %}

***

## Quantisation levels in use

The TensorX catalogue uses three quantisation levels today:

| Level                            | Used by                                                                                                                                                                                         | Why                                                                                                                                                                                         |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`fp8`** (8-bit floating point) | Almost every LLM on the platform, including the GLM family (`z-ai/glm-5`, `z-ai/glm-5-turbo`, `z-ai/glm-5.1`, `z-ai/glm-5.2`, `z-ai/glm-5v-turbo`), DeepSeek, Llama, Qwen, Mixtral, and MiniMax | Best precision-vs-throughput trade-off on NVIDIA B200 and B300 hardware. Quality difference versus higher precisions is negligible on standard evaluation suites.                           |
| **`int4`** (4-bit integer)       | The Kimi K2 family only (`moonshotai/Kimi-K2.6`, `moonshotai/kimi-k2.5`, `moonshotai/kimi-k2.7-code`)                                                                                           | These models ship with Moonshot's native INT4 quantisation-aware-trained weights. Using the QAT weights preserves quality at much lower memory and latency than post-training quantisation. |
| **`fp4`** (4-bit floating point) | The `deepseek-v4-flash-backup` model only                                                                                                                                                       | Served at `fp4` for maximum throughput on the backup deployment.                                                                                                                            |

Non-LLM deployments (text-to-speech, speech-to-text) do not carry a quantisation label.

A small number of LLM deployments also report no quantisation label on `/v1/model/info` (the field is `null`).

***

## Checking the quantisation for a specific model

The model catalogue endpoint exposes the quantisation per model. This is the canonical answer and will reflect any future change to how a model is served.

```bash
curl https://api.tensorx.ai/v1/model/info \
  -H "Authorization: Bearer $TENSORX_API_KEY" \
  | jq '.data[] | {model: .model_name, quantization: .model_info.quantization}'
```

### Example response (excerpt)

```json
[
  { "model": "z-ai/glm-5.2",         "quantization": "fp8"  },
  { "model": "z-ai/glm-5.1",         "quantization": "fp8"  },
  { "model": "minimax/minimax-m2.5", "quantization": "fp8"  },
  { "model": "moonshotai/kimi-k2.5", "quantization": "int4" },
  { "model": "moonshotai/Kimi-K2.6", "quantization": "int4" },
  { "model": "chatterbox-turbo",     "quantization": null   }
]
```

Each entry in the full `/v1/model/info` response carries a `model_info.quantization` field. If the field is `null`, the model is a non-LLM deployment (audio).

***

## FAQ

### Do you offer this model at a different quantisation level?

Not on the shared platform. TensorX does not publish the same model at multiple quantisation levels - there is one served version per model ID, at the quantisation shown on `/v1/model/info`.

If you have a specific requirement (for example, a particular model served at `bf16` or `fp16` for a regulated workload or for a benchmark methodology that requires it), that is a [Dedicated Inference](https://tensorx.ai/dedicated-inference) engagement rather than a parallel SKU on the shared platform.

### Is there a quality difference between `fp8` and higher precisions?

For the models on the TensorX catalogue, the quality difference between the `fp8` deployment and a higher-precision version of the same weights is negligible on standard evaluation suites (MMLU, HumanEval, GSM8K, AIME, and similar). Where benchmarks are run on quantised serving, we report numbers from the served `fp8` version, not from a hypothetical higher-precision copy.

### Why is Kimi K2 served at `int4` rather than `fp8`?

The Kimi K2 family is published by Moonshot with native INT4 quantisation-aware-trained weights. Using the QAT version preserves the model's quality while reducing memory footprint and latency significantly. Quantising those weights up to `fp8` would offer no quality benefit and would cost throughput.

### Will the quantisation for a model ever change?

It can. If a model provider releases an updated weight format, or if a new quantisation method gives a clear quality-vs-throughput improvement, we will update the served version. The `model_info.quantization` field on `/v1/model/info` is always the source of truth.

***

## See also

* [Models](/api-reference/models) - Available models on the platform
* [Chat Completions](/api-reference/chat-completions) - API endpoint documentation
* [Rate Limits](/api-reference/rate-limits) - Throughput and request limits


# API Examples

Sample curl commands to get you started with the TensorX API. All examples use the OpenAI-compatible endpoint.

{% hint style="info" %}
Replace `YOUR_API_KEY` with your actual TensorX API key from [app.tensorx.ai](https://app.tensorx.ai).
{% endhint %}

***

## Basic Chat Completion

A simple chat request with GLM-5.1:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.1",
    "messages": [
      {"role": "user", "content": "What is the capital of France?"}
    ]
  }'
```

***

## Multi-turn Conversation

Include conversation history for context:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.1",
    "messages": [
      {"role": "user", "content": "My name is Alex"},
      {"role": "assistant", "content": "Nice to meet you, Alex! How can I help you today?"},
      {"role": "user", "content": "What is my name?"}
    ]
  }'
```

***

## Streaming Response

Get responses token-by-token for real-time output:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.1",
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a haiku about coding"}
    ]
  }'
```

***

## Code Generation

Ask for code with a system prompt:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.1",
    "messages": [
      {"role": "system", "content": "You are an expert Python developer. Write clean, well-documented code."},
      {"role": "user", "content": "Write a function to check if a string is a palindrome"}
    ]
  }'
```

***

## With Temperature Control

Adjust creativity with temperature (0.0 = focused, 1.0 = creative):

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.1",
    "temperature": 0.7,
    "messages": [
      {"role": "user", "content": "Give me 3 creative startup ideas"}
    ]
  }'
```

***

## Using MiniMax Models

Switch to MiniMax-M2.5 for different capabilities:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "minimax/minimax-m2.5",
    "messages": [
      {"role": "user", "content": "Explain quantum computing in simple terms"}
    ]
  }'
```

***

## List Available Models

Check which models are available:

```bash
curl https://api.tensorx.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"
```

***

## Python Example

Using the OpenAI Python SDK:

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

response = client.chat.completions.create(
    model="z-ai/glm-5.1",
    messages=[
        {"role": "user", "content": "Hello, world!"}
    ]
)

print(response.choices[0].message.content)
```

***

## JavaScript/Node.js Example

Using the OpenAI Node.js SDK:

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.tensorx.ai/v1'
});

const response = await client.chat.completions.create({
  model: 'z-ai/glm-5.1',
  messages: [
    { role: 'user', content: 'Hello, world!' }
  ]
});

console.log(response.choices[0].message.content);
```

***

## Available Models

| Model            | ID                          | Best For                        |
| ---------------- | --------------------------- | ------------------------------- |
| **GLM-5.1** ⭐    | `z-ai/glm-5.1`              | Coding, reasoning, general use  |
| **MiniMax-M2.5** | `minimax/minimax-m2.5`      | Reasoning, functions            |
| **Kimi-K2.5**    | `moonshotai/kimi-k2.5`      | Vision, functions, long context |
| **MiniMax-M2**   | `minimax/minimax-m2`        | Coding, fast responses          |
| GLM 5.2          | `z-ai/glm-5.2`              | General chat, reasoning         |
| DeepSeek R1      | `deepseek/deepseek-r1-0528` | Complex problem solving         |

For the full list of models and pricing, visit [tensorx.ai](https://tensorx.ai).


# Rate Limits

Understanding API rate limits and how to manage them effectively.

***

## Current Limits

| Resource                      | Limit     |
| ----------------------------- | --------- |
| **Requests per minute (RPM)** | 60        |
| **Tokens per minute (TPM)**   | 2,000,000 |

These limits apply **per API key**. Each key you create has its own independent rate limit.

***

## How Token Limits Work

When a request arrives, TensorX **reserves** your `max_tokens` value against your TPM allowance while the request is in flight. This is a reservation, not actual consumption - the reserved amount is released back once the request completes.

### Why This Matters

If `max_tokens` is set very high (e.g. `1048576`), each request reserves \~1M tokens against your TPM allowance — even if the actual output is only a few thousand tokens.

**Example:** With a 2M TPM allowance and `max_tokens: 1048576`, only \~2 concurrent requests fit before hitting the TPM limit.

### Recommended Values

Set `max_tokens` to a realistic value so each request only reserves what it plausibly needs:

| Use case          | Suggested `max_tokens` |
| ----------------- | ---------------------- |
| Coding tasks      | 8192–16384             |
| Short responses   | 4096                   |
| Long-form content | 16384–32768            |

{% hint style="warning" %}
Some editors and IDEs (e.g. Zed) default `max_tokens` to the full context window size (1,048,576). If you're getting TPM 429 errors after just a few requests, check your client's `max_tokens` setting.
{% endhint %}

***

## Need Higher Limits?

Our standard limits support most development and production workloads. We're committed to supporting growing projects while ensuring platform stability for all users.

Shared rate limits scale with your **total consumed spend** - the cumulative dollar value of tokens you have actually used on the platform. This is not the same as your credit balance. Depositing credits does not trigger a tier upgrade; only actual usage counts.

Tiers are applied manually once your consumed spend crosses the threshold. Should you wish to avail of a higher tier, ensure you have used your spend as noted below and reach out to our support team. These tiers will affect your rate limits, but will not affect direct throughput (TPS). The tiers below are best-effort and are not guaranteed throughput:

| Total spend (USD) | Requests per minute | Tokens per minute |
| ----------------- | ------------------- | ----------------- |
| Default           | 60                  | 2,000,000         |
| $250              | up to 600           | 20,000,000        |
| $1,000            | 2,500               | 30,000,000        |
| $2,500            | 5,000               | 180,000,000       |

Beyond the top tier, or when you need guaranteed throughput, we move you to dedicated inference.

**For enterprise workloads requiring higher limits:**

📧 **Contact us**: <support@tensorx.ai>

Include in your request:

* Your use case and expected scale
* Current bottlenecks you're experiencing
* Your account email

{% hint style="info" %}
**Enterprise clients** needing volume beyond the top tier, or guaranteed throughput rather than best-effort shared limits, move to dedicated inference. We'll work with you to find the right balance for your needs.
{% endhint %}

***

## What Happens When You Hit a Limit

When you exceed rate limits, the API returns a `429 Too Many Requests` error:

```json
{
  "error": {
    "message": "Rate limit exceeded for api_key: xxx...xxx. Limit type: requests. Current limit: 60, Remaining: 0. Limit resets at: 2026-03-21 20:38:07 UTC",
    "type": "None",
    "param": "None",
    "code": "429"
  }
}
```

The error message includes:

* Which limit you hit (requests or tokens)
* Your current limit and remaining count
* When the limit resets

***

## Checking Your Rate Limit Status

Every API response includes headers showing your current usage:

| Header                                   | Example Value | Description                    |
| ---------------------------------------- | ------------- | ------------------------------ |
| `x-ratelimit-api_key-limit-requests`     | 60            | Max requests per minute        |
| `x-ratelimit-api_key-remaining-requests` | 45            | Requests remaining this minute |
| `x-ratelimit-api_key-limit-tokens`       | 2000000       | Max tokens per minute          |
| `x-ratelimit-api_key-remaining-tokens`   | 1850000       | Tokens remaining this minute   |

Check these headers to monitor your usage before hitting limits.

***

## Handling Rate Limits

### Retry with Exponential Backoff

The best practice is to retry with increasing delays:

{% tabs %}
{% tab title="Python" %}

```python
import time
from openai import OpenAI, RateLimitError

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tensorx.ai/v1"
)

def call_with_retry(messages, max_retries=5):
    for attempt in range(max_retries):
        try:
            return client.chat.completions.create(
                model="z-ai/glm-5.2",
                messages=messages
            )
        except RateLimitError:
            if attempt == max_retries - 1:
                raise
            wait_time = 2 ** attempt  # 1, 2, 4, 8, 16 seconds
            print(f"Rate limited. Waiting {wait_time}s...")
            time.sleep(wait_time)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
async function callWithRetry(messages, maxRetries = 5) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await client.chat.completions.create({
        model: 'z-ai/glm-5.2',
        messages
      });
    } catch (error) {
      if (error.status !== 429 || attempt === maxRetries - 1) {
        throw error;
      }
      const waitTime = Math.pow(2, attempt) * 1000;
      console.log(`Rate limited. Waiting ${waitTime}ms...`);
      await new Promise(r => setTimeout(r, waitTime));
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Spread Out Requests

If you're making many requests, add small delays between them:

```python
import time

for item in items:
    response = make_api_call(item)
    time.sleep(1)  # Wait 1 second between requests
```

***

## Tips to Stay Under Limits

| Tip                             | How It Helps                                                                                                                                                   |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Batch similar requests**      | Fewer API calls                                                                                                                                                |
| **Cache responses**             | Don't repeat identical queries                                                                                                                                 |
| **Use streaming**               | One request for long outputs                                                                                                                                   |
| **Set appropriate max\_tokens** | Set `max_tokens` to a realistic value (e.g. 8192) to avoid exhausting your token limit prematurely. See [How Token Limits Work](#how-token-limits-work) above. |
| **Queue requests**              | Smooth out traffic spikes                                                                                                                                      |

***

## Monitoring Your Usage

Check your request patterns in your [Usage Dashboard](https://app.tensorx.ai/dashboard/usage):

* See request counts over time
* Identify peak usage periods
* Spot patterns that might cause rate limiting


# Prompt Caching

How prompt caching works on TensorX.

## Does TensorX offer prompt caching?

Yes. Our serving stack uses KV caching at the inference layer, which is how modern inference engines work in general. When repeated requests share a common prefix, or land on the same replica that has handled a similar prefix recently, reuse of cached state makes those requests faster.

This is **best-effort rather than guaranteed**. We run multiple replicas of popular models for load and resilience, so a follow-up request can land on a different replica without that prefix warm, in which case it is recomputed from scratch.

## Cache-hit pricing

Models that support prompt caching have separate, lower rates for cached input tokens. When a request hits a warm replica with a matching prefix, the cached portion of the input is billed at the model's **cache-read** rate rather than the standard input rate. Across the catalogue the cache-read rate is roughly a quarter of the input rate (about a 75% discount); the exact per-model figure is available from the API shown below. Populating the cache on the first hit uses the **cache-write** rate. You don't need to do anything to opt in; pricing is applied automatically based on what the serving layer reports back to the billing layer.

Because cache hits are best-effort across replicas, the saving applies on a per-request basis rather than as a guaranteed discount on every call. In steady traffic with consistent prefixes you can expect the cache-read rate to apply most of the time; under heavy load or after idle periods, more of your requests will be billed at the standard input rate.

We will surface the per-model cache rates on the public pricing page shortly. In the meantime, you can retrieve them yourself today directly from the API:

```bash
curl -H "Authorization: Bearer $TENSORX_API_KEY" \
  https://api.tensorx.ai/v1/model/info \
  | jq '.data[] | select(.model_info.supports_prompt_caching == true) | {
      model: .model_name,
      input_cost_per_token: .model_info.input_cost_per_token,
      cache_read_input_token_cost: .model_info.cache_read_input_token_cost,
      cache_creation_input_token_cost: .model_info.cache_creation_input_token_cost
    }'
```

The `supports_prompt_caching` flag tells you whether a given model has caching enabled. Audio models and a small number of LLMs don't expose caching today.

## Measuring cache usage

Because hits are best-effort, you can confirm what actually got cached from the `usage` object the API returns on each response. On chat completions, `prompt_tokens_details.cached_tokens` reports how many of the prompt tokens were served from cache; comparing that against `prompt_tokens` tells you the share of the input that hit the cache (and so was billed at the cheaper cache-read rate). Aggregate these fields across calls to see how often steady, shared-prefix traffic is hitting the cache.

## What this means in practice

* **Repeated identical or near-identical prompts**, especially when sent in close succession, are likely to benefit from KV cache reuse on a warm replica.
* **Long shared system prompts** across many calls (a common pattern for agentic workflows) will often hit the cache when traffic is steady, and will miss when load spreads requests across replicas.
* **Cold starts** (the first request to a freshly scaled replica, or after a long idle period) will not benefit from caching.

## Caching and zero data retention

Prompt caching reuses a matching prompt prefix when a recent request has warmed it, on a best-effort basis across the serving fleet, and is unrelated to our zero-data-retention policy. ZDR governs what we do not retain after a request completes (prompts, completions, logs of either).

KV state lives in GPU memory only and is never written to disk or included in any retained dataset. Prompt caching works by reusing this state, so cached blocks do persist in memory beyond the single request that created them: a later request that shares a prefix can reuse them. They remain transient in-memory state, evicted under memory pressure or after idle periods, and nothing about the prompt or completion is persisted to storage at any point.


# Claude Code CLI

Claude Code is Anthropic's official AI coding assistant that runs in your terminal. TensorX provides an API-compatible endpoint allowing you to use Claude Code with open-source models like **GLM-5.1** and **MiniMax-M2** at a fraction of the cost.

## Key Benefits

* 🚀 **Powerful open-source models** - GLM-5.1, MiniMax-M2.5, MiniMax-M2, and more
* 💰 **Pay-as-you-go pricing** through TensorX
* ✨ **Full Claude Code features** - file editing, bash commands, multi-turn conversations
* 🇪🇺 **EU-hosted infrastructure** with zero data retention

## Prerequisites

* Node.js 18 or newer
* A TensorX API key ([get one here](https://app.tensorx.ai))
* Terminal access (macOS, Linux, or Windows with WSL)

## Installation

Install Claude Code globally:

```bash
npm install -g @anthropic-ai/claude-code
```

Verify installation:

```bash
claude --version
```

***

## Quick Start - No Account Required

For quick queries and scripting, use **print mode** which doesn't require any Anthropic account.

### Example with GLM-5.1 (Recommended)

```bash
export ANTHROPIC_API_KEY="<YOUR_TENSORX_API_KEY>"
export ANTHROPIC_BASE_URL="https://api.tensorx.ai"
export ANTHROPIC_MODEL="z-ai/glm-5.1"

claude -p "Explain what a REST API is"
```

### Example with MiniMax-M2

```bash
export ANTHROPIC_API_KEY="<YOUR_TENSORX_API_KEY>"
export ANTHROPIC_BASE_URL="https://api.tensorx.ai"
export ANTHROPIC_MODEL="minimax/minimax-m2"

claude -p "Write a Python function to reverse a string"
```

{% hint style="info" %}
Print mode (`-p`) outputs the response and exits. For interactive development sessions with file editing and bash commands, see **Interactive Mode Setup** below.
{% endhint %}

***

## Interactive Mode Setup

Interactive mode provides the full Claude Code experience with file editing, bash commands, and multi-turn conversations. Requires **one-time** free Anthropic account setup.

### Step 1: Initial Setup (One-Time Only)

Run `claude` and complete the OAuth login:

```bash
claude
```

Select **"Anthropic Console account"** when prompted and follow the browser login. A free Anthropic account works - you won't be charged by Anthropic as all requests route through TensorX.

### Step 2: Configure TensorX

Create or edit `~/.claude/settings.json`:

{% tabs %}
{% tab title="GLM-5.1 (Recommended)" %}

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorx.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORX_API_KEY>",
    "ANTHROPIC_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_SMALL_FAST_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "z-ai/glm-5.1",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

{% endtab %}

{% tab title="MiniMax-M2.5" %}

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorx.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORX_API_KEY>",
    "ANTHROPIC_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_SMALL_FAST_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "minimax/minimax-m2.5",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

{% endtab %}

{% tab title="MiniMax-M2" %}

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorx.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORX_API_KEY>",
    "ANTHROPIC_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_SMALL_FAST_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "minimax/minimax-m2",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

{% endtab %}
{% endtabs %}

### Step 3: Start Using Claude Code

Navigate to your project and run:

```bash
cd /path/to/your/project
claude
```

{% hint style="warning" %}
You'll see a warning about auth conflict - **this is normal and can be ignored.** All requests now route through TensorX!
{% endhint %}

### Why All Model Variables Are Required

Claude Code uses different models for different internal tasks:

| Variable                         | Purpose                             |
| -------------------------------- | ----------------------------------- |
| `ANTHROPIC_MODEL`                | Main model for conversations        |
| `ANTHROPIC_SMALL_FAST_MODEL`     | Quick background tasks              |
| `ANTHROPIC_DEFAULT_HAIKU_MODEL`  | Token counting and small operations |
| `ANTHROPIC_DEFAULT_SONNET_MODEL` | Standard coding tasks               |
| `ANTHROPIC_DEFAULT_OPUS_MODEL`   | Complex reasoning tasks             |

{% hint style="danger" %}
**Important:** If you don't set all of these, Claude Code will try to call `claude-haiku-4-5` or other Anthropic models which don't exist on TensorX, causing errors.
{% endhint %}

***

## Available Models

### Recommended Models

| Model            | ID                     | Best For                        |
| ---------------- | ---------------------- | ------------------------------- |
| **GLM-5.1** ⭐    | `z-ai/glm-5.1`         | Coding, reasoning, general use  |
| **MiniMax-M2.5** | `minimax/minimax-m2.5` | Reasoning, functions            |
| **Kimi-K2.5**    | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| **MiniMax-M2**   | `minimax/minimax-m2`   | Coding, fast responses          |

### Other Supported Models

| Model        | ID                          |
| ------------ | --------------------------- |
| GLM 5.2      | `z-ai/glm-5.2`              |
| DeepSeek R1  | `deepseek/deepseek-r1-0528` |
| MiniMax M2.5 | `minimax/minimax-m2.5`      |

***

## Switching Models

To switch models, update **all** model variables in `~/.claude/settings.json`:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorx.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORX_API_KEY>",
    "ANTHROPIC_MODEL": "<MODEL_ID>",
    "ANTHROPIC_SMALL_FAST_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "<MODEL_ID>",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

Replace `<MODEL_ID>` with your chosen model (e.g., `z-ai/glm-5.1`).

After editing, **start a new Claude Code session** for changes to take effect.

***

## Troubleshooting

### "claude-haiku-4-5 not found" or similar model errors

**Solution:** You haven't set all model aliases. Ensure your `settings.json` includes:

* `ANTHROPIC_DEFAULT_HAIKU_MODEL`
* `ANTHROPIC_DEFAULT_SONNET_MODEL`
* `ANTHROPIC_DEFAULT_OPUS_MODEL`
* `ANTHROPIC_SMALL_FAST_MODEL`

All should be set to your chosen TensorX model.

### Auth conflict warning

**Message:** `⚠Auth conflict: Both a token (ANTHROPIC_AUTH_TOKEN) and an API key...`

**Solution:** This warning is normal and can be ignored. Claude Code is using your `ANTHROPIC_AUTH_TOKEN` from `settings.json` which points to TensorX. Your requests are routing correctly.

### OAuth login still required after configuration

**Solution:** Interactive mode requires a one-time Anthropic OAuth. This is a Claude Code requirement. After completing it once, your `settings.json` config will route all actual API requests through TensorX.

For scripting without OAuth, use print mode: `claude -p "your prompt"`

### Configuration not taking effect

**Solution:**

1. Close all Claude Code sessions
2. Verify `~/.claude/settings.json` has correct JSON syntax
3. Open a new terminal window
4. Run `claude` again

### Timeout errors

**Solution:** Increase `API_TIMEOUT_MS` in your `settings.json`:

```json
"API_TIMEOUT_MS": "6000000"
```

***

## FAQ

**Q: Do I need an Anthropic account?**

For interactive mode, yes - a free account for one-time OAuth. For print mode (`-p` flag), no account is needed.

**Q: Will I be charged by Anthropic?**

No. All API requests route through TensorX. The Anthropic OAuth is only for authentication, not billing.

**Q: Why do I need to set all the model variables?**

Claude Code uses different models for different internal tasks (token counting, background operations, etc.). Setting all aliases ensures everything routes to your chosen TensorX model.

**Q: Can I use different models for different tasks?**

Yes! You can set `ANTHROPIC_DEFAULT_HAIKU_MODEL` to a faster/cheaper model and `ANTHROPIC_DEFAULT_OPUS_MODEL` to a more capable one.

**Q: What's the difference between ANTHROPIC\_API\_KEY and ANTHROPIC\_AUTH\_TOKEN?**

Both work, but `ANTHROPIC_AUTH_TOKEN` is preferred for custom endpoints. Use `ANTHROPIC_AUTH_TOKEN` in `settings.json`.

**Q: Does TensorX support the Anthropic Messages API (`/v1/messages`)?**

Yes. TensorX exposes an Anthropic-compatible `/v1/messages` endpoint at `https://api.tensorx.ai`, which is what Claude Code targets when you set `ANTHROPIC_BASE_URL`. Standard per-key rate limits apply (see [Rate Limits](/api-reference/rate-limits)); there is no separate endpoint to enable.


# Claude Code VS Code

The Claude Code VS Code extension can also be configured to use TensorX models.

{% hint style="info" %}
This guide covers the VS Code extension. For the terminal CLI, see [Claude Code CLI](/ai-coding-assistants/claude-code-cli).
{% endhint %}

## Installation

1. Open VS Code Extensions (`Ctrl+Shift+X` / `Cmd+Shift+X`)
2. Search for **"Claude Code"**
3. Click **Install**

## Configuration

Open VS Code settings (`Cmd/Ctrl + ,`) and search for "Claude Code". Click **"Edit in settings.json"** and add:

```json
{
  "claudeCode.environmentVariables": [
    {
      "name": "ANTHROPIC_BASE_URL",
      "value": "https://api.tensorx.ai"
    },
    {
      "name": "ANTHROPIC_AUTH_TOKEN",
      "value": "<YOUR_TENSORX_API_KEY>"
    },
    {
      "name": "ANTHROPIC_MODEL",
      "value": "z-ai/glm-5.1"
    },
    {
      "name": "ANTHROPIC_SMALL_FAST_MODEL",
      "value": "z-ai/glm-5.1"
    },
    {
      "name": "ANTHROPIC_DEFAULT_HAIKU_MODEL",
      "value": "z-ai/glm-5.1"
    },
    {
      "name": "ANTHROPIC_DEFAULT_SONNET_MODEL",
      "value": "z-ai/glm-5.1"
    },
    {
      "name": "ANTHROPIC_DEFAULT_OPUS_MODEL",
      "value": "z-ai/glm-5.1"
    },
    {
      "name": "API_TIMEOUT_MS",
      "value": "3000000"
    },
    {
      "name": "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
      "value": "1"
    }
  ]
}
```

{% hint style="danger" %}
**Important:** You must set ALL model variables (`ANTHROPIC_MODEL`, `ANTHROPIC_SMALL_FAST_MODEL`, `ANTHROPIC_DEFAULT_HAIKU_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`). Missing any will cause Claude Code to try calling Anthropic models directly, resulting in errors.
{% endhint %}

## Available Models

| Model            | Value                  | Best For                        |
| ---------------- | ---------------------- | ------------------------------- |
| **GLM-5.1** ⭐    | `z-ai/glm-5.1`         | Coding, reasoning, general use  |
| **MiniMax-M2.5** | `minimax/minimax-m2.5` | Reasoning, functions            |
| **Kimi-K2.5**    | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| **MiniMax-M2**   | `minimax/minimax-m2`   | Coding, fast responses          |

## Switching Models

To switch models, update **all** model values in your VS Code `settings.json`:

1. Replace `z-ai/glm-5.1` with your chosen model ID in all five places
2. Restart VS Code or reload the window

## One-Time OAuth

Like the CLI, the VS Code extension requires a one-time Anthropic OAuth for interactive features. A free Anthropic account works - you won't be charged by Anthropic as all requests route through TensorX.


# Cursor

Use TensorX models with [Cursor](https://cursor.sh), the AI-powered code editor.

## Installation

Download and install [Cursor](https://cursor.sh).

## Configuration

{% hint style="warning" %}
**Important:** Clear existing OpenAI environment variables before configuration
{% endhint %}

### Step 1: Configure API Settings

1. Open Cursor **Settings** → **Models**
2. Expand **API Keys** section
3. Enable **Override OpenAI Base URL**
4. Enter Base URL: `https://api.tensorx.ai/v1`
5. Enter your TensorX API key in the **OpenAI API Key** field
6. Click the verification button to test the connection

### Step 2: Add Custom Model

1. In **Models** section, click **Add Custom Model**
2. Enter model name: `minimax/minimax-m2`
3. Click **Add**
4. Enable the model
5. Select it in the chat panel

## Available Models

| Model             | ID                     | Best For                        |
| ----------------- | ---------------------- | ------------------------------- |
| GLM-5.1 (Default) | `z-ai/glm-5.1`         | Coding, reasoning, functions    |
| MiniMax-M2.5      | `minimax/minimax-m2.5` | Reasoning, functions            |
| Kimi-K2.5         | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| MiniMax-M2        | `minimax/minimax-m2`   | Coding, fast responses          |


# Cline

Use TensorX models with [Cline](https://github.com/cline/cline), the autonomous coding agent for VS Code.

## Installation

1. Open VS Code Extensions
2. Search for **"Cline"**
3. Click **Install**
4. Restart VS Code

## Configuration

1. Click **Use your own API key** in Cline
2. Under **API Provider**, select **OpenAI Compatible**
3. Configure the following:

| Setting  | Value                       |
| -------- | --------------------------- |
| Base URL | `https://api.tensorx.ai/v1` |
| API Key  | Your TensorX API key        |
| Model    | `minimax/minimax-m2`        |

4. Click **Let's go!** and then **Done**

## Available Models

| Model             | ID                     | Best For                        |
| ----------------- | ---------------------- | ------------------------------- |
| GLM-5.1 (Default) | `z-ai/glm-5.1`         | Coding, reasoning, functions    |
| MiniMax-M2.5      | `minimax/minimax-m2.5` | Reasoning, functions            |
| Kimi-K2.5         | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| MiniMax-M2        | `minimax/minimax-m2`   | Coding, fast responses          |

## Tips

* Cline works best with models that have strong reasoning capabilities
* MiniMax-M2/M2.5 is recommended for complex multi-file operations
* Use GLM-5.1 when you need function/tool calling


# Kilo Code

Use TensorX models with [Kilo Code](https://kilo.ai/), the AI-powered coding assistant for VS Code.

## Installation

1. Open VS Code Extensions
2. Search for **"Kilo Code"**
3. Click **Install**
4. Restart VS Code

## Configuration

1. Open the Kilo Code sidebar by clicking the Kilo Code icon in the VS Code Side Bar
2. Click the **⚙️ settings icon** to open the settings panel
3. Under **API Provider**, select **OpenAI Compatible**
4. Configure the following settings:

| Setting  | Value                                      |
| -------- | ------------------------------------------ |
| Base URL | `https://api.tensorx.ai/v1`                |
| API Key  | Your TensorX API key                       |
| Model    | Enter your model ID (e.g., `z-ai/glm-5.1`) |

5. Optionally expand **Model Configuration** to customize:
   * Max Output Tokens
   * Context Window
   * Image Support
   * Input/Output Price
6. Click **Let's go!** to save your settings

## Available Models

| Model        | ID                     | Best For                        |
| ------------ | ---------------------- | ------------------------------- |
| GLM-5.1 ⭐    | `z-ai/glm-5.1`         | Coding, reasoning, functions    |
| MiniMax-M2.5 | `minimax/minimax-m2.5` | Reasoning, functions            |
| Kimi-K2.5    | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| MiniMax-M2   | `minimax/minimax-m2`   | Coding, fast responses          |

## Using Different Modes

Kilo Code supports multiple modes optimized for different tasks:

| Mode          | Description                                    |
| ------------- | ---------------------------------------------- |
| **Code**      | General-purpose coding tasks                   |
| **Architect** | Planning and technical leadership              |
| **Ask**       | Answering questions and providing information  |
| **Debug**     | Systematic problem diagnosis                   |
| **Custom**    | Create specialized personas for specific tasks |

## Tips

* **For tool-heavy workflows**: Use `z-ai/glm-5.1` which has strong function calling support
* **For reasoning tasks**: Use `minimax/minimax-m2` for complex multi-step operations

## Troubleshooting

| Issue             | Solution                                       |
| ----------------- | ---------------------------------------------- |
| "Invalid API Key" | Verify your TensorX API key is correct         |
| "Model Not Found" | Check the model ID matches exactly             |
| Connection errors | Ensure Base URL is `https://api.tensorx.ai/v1` |

## Resources

* [Kilo Code Documentation](https://kilo.ai/docs)
* [Kilo Code OpenAI Compatible Guide](https://kilo.ai/docs/providers/openai-compatible)
* [TensorX API Reference](/api-reference/overview)


# OpenHands

Use TensorX models with [OpenHands](https://docs.openhands.dev/), the open-source AI software developer.

## Prerequisites

OpenHands runs as a Docker container. Ensure you have Docker installed and running.

## Quick Start

1. Pull and run OpenHands:

```bash
docker pull docker.openhands.dev/openhands/runtime:1.0-nikolaik
docker run -it --rm --pull=always \
    -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.openhands.dev/openhands/runtime:1.0-nikolaik \
    -e LOG_ALL_EVENTS=true \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v ~/.openhands:/.openhands \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name openhands-app \
    docker.openhands.dev/openhands/openhands:1.0
```

2. Open `http://localhost:3000` in your browser

## Configuration

1. When prompted, click **"see advanced settings"** to open the LLM Settings page
2. Enable the **Advanced** toggle at the top
3. Configure the following:

| Setting      | Value                       |
| ------------ | --------------------------- |
| Custom Model | `openai/z-ai/glm-5.1`       |
| Base URL     | `https://api.tensorx.ai/v1` |
| API Key      | Your TensorX API key        |

4. Click **Save Settings**

{% hint style="info" %}
**Note:** The Custom Model format is `openai/<model-id>`. The `openai/` prefix tells OpenHands to use the OpenAI-compatible API format.
{% endhint %}

## Available Models

| Model        | Custom Model Value            |
| ------------ | ----------------------------- |
| GLM-5.1 ⭐    | `openai/z-ai/glm-5.1`         |
| MiniMax-M2.5 | `openai/minimax/minimax-m2.5` |
| Kimi-K2.5    | `openai/moonshotai/kimi-k2.5` |
| MiniMax-M2   | `openai/minimax/minimax-m2`   |

## Tips

* **Model selection**: GLM-5.1 is recommended for OpenHands due to strong tool calling support
* **Context size**: OpenHands requires a large context size to work properly
* **Cost management**: OpenHands will issue many prompts - monitor your usage

## Troubleshooting

| Issue                 | Solution                                        |
| --------------------- | ----------------------------------------------- |
| Empty responses       | Check model ID is correct with `openai/` prefix |
| Connection errors     | Verify Base URL is `https://api.tensorx.ai/v1`  |
| Authentication errors | Verify your API key is correct                  |

## Resources

* [OpenHands Documentation](https://docs.openhands.dev/)
* [OpenHands LLM Configuration](https://docs.openhands.dev/openhands/usage/llms/llms)
* [TensorX API Reference](/api-reference/overview)


# Roo Code

Use TensorX models as your AI coding agent in VS Code with Roo Code — featuring multiple specialized modes, custom instructions, and multi-agent orchestration.

***

## Overview

[Roo Code](https://roocode.com) is an open-source AI coding agent for VS Code. It provides a full dev team of AI agents in your editor with specialized modes for coding, debugging, architecture, and more. Roo Code supports OpenAI-compatible API providers, making it easy to connect to TensorX.

{% hint style="success" %}
**Why Roo Code + TensorX?**

* 🧠 **Multiple modes** — Code, Architect, Debug, Ask, and Orchestrator built in
* 🔄 **Boomerang orchestration** — Coordinate multi-step tasks across modes
* 📁 **Full codebase access** — Read, edit, run commands, and browse the web
* 🎯 **Custom modes** — Create specialized personas with file restrictions
* 💰 **Cost-effective** — Use powerful open-source models at a fraction of the cost
  {% endhint %}

***

## Prerequisites

* **VS Code** (latest version recommended)
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Setup

### Step 1: Install Roo Code

1. Open VS Code
2. Go to the **Extensions** panel (`Ctrl+Shift+X` / `Cmd+Shift+X`)
3. Search for **"Roo Code"**
4. Click **Install**

### Step 2: Configure TensorX

1. Open the Roo Code panel (click the Roo Code icon in the sidebar)
2. Click the **gear icon** to open settings
3. Configure the following:

| Setting          | Value                       |
| ---------------- | --------------------------- |
| **API Provider** | `OpenAI Compatible`         |
| **Base URL**     | `https://api.tensorx.ai/v1` |
| **API Key**      | Your TensorX API key        |
| **Model**        | `z-ai/glm-5.1`              |

### Step 3: Configure Model Settings (Optional)

Under **Model Configuration**, you can customize:

| Setting               | Recommended Value                                                 |
| --------------------- | ----------------------------------------------------------------- |
| **Context Window**    | See model specs on [tensorx.ai/models](https://tensorx.ai/models) |
| **Max Output Tokens** | `16384`                                                           |

***

## Using Modes

Roo Code includes five built-in modes, each with different capabilities:

| Mode               | Slash Command   | Best For                                        |
| ------------------ | --------------- | ----------------------------------------------- |
| **Code** (default) | `/code`         | Writing code, implementing features, debugging  |
| **Architect**      | `/architect`    | System design, planning, architecture decisions |
| **Debug**          | `/debug`        | Tracking bugs, diagnosing errors                |
| **Ask**            | `/ask`          | Code explanation, learning, technical questions |
| **Orchestrator**   | `/orchestrator` | Multi-step projects, coordinating across modes  |

Switch modes using:

* The dropdown menu (left of chat input)
* Slash commands: `/code`, `/architect`, `/debug`, `/ask`, `/orchestrator`
* Keyboard shortcut: `Cmd+.` (macOS) or `Ctrl+.` (Windows/Linux)

***

## Recommended Models

| Use Case         | Model                       | Why                                      |
| ---------------- | --------------------------- | ---------------------------------------- |
| **Coding** ⭐     | `z-ai/glm-5.1`              | Top coding performance, strong reasoning |
| **Reasoning**    | `minimax/minimax-m2.5`      | Complex analysis, function calling       |
| **Architecture** | `deepseek/deepseek-r1-0528` | Deep reasoning for design decisions      |
| **Vision**       | `moonshotai/kimi-k2.5`      | Image understanding, long context        |
| **General chat** | `z-ai/glm-5.2`              | Balanced performance and cost            |
| **Fast tasks**   | `minimax/minimax-m2`        | Quick responses, cost-sensitive          |

{% hint style="info" %}
**Tip:** Use API Configuration Profiles to set different models for different modes — e.g., GLM-5.1 for Code mode, DeepSeek R1 for Architect mode.
{% endhint %}

***

## API Configuration Profiles

Roo Code supports per-mode API profiles, so you can use different models for different tasks:

1. Open Roo Code settings (gear icon)
2. Navigate to **API Configuration Profiles**
3. Create profiles for each mode with different TensorX models

Example setup:

| Profile   | Provider          | Model                       | Use With       |
| --------- | ----------------- | --------------------------- | -------------- |
| Coding    | OpenAI Compatible | `z-ai/glm-5.1`              | Code mode      |
| Reasoning | OpenAI Compatible | `deepseek/deepseek-r1-0528` | Architect mode |
| Fast      | OpenAI Compatible | `minimax/minimax-m2`        | Ask mode       |

All profiles use the same Base URL (`https://api.tensorx.ai/v1`) and API key.

***

## Custom Modes

Create specialized modes by adding a `.roomodes` file to your project root:

```yaml
customModes:
  - slug: reviewer
    name: "Code Reviewer"
    roleDefinition: >-
      You are a senior code reviewer focused on code quality,
      security, and best practices.
    groups:
      - read
      - browser
    customInstructions: |
      Review code for bugs, security issues, and style.
      Suggest improvements with specific examples.

  - slug: docs-writer
    name: "Documentation Writer"
    roleDefinition: You are a technical writer specializing in clear documentation.
    groups:
      - read
      - - edit
        - fileRegex: \.(md|mdx)$
          description: Markdown files only
      - browser
```

***

## Troubleshooting

### Model Not Responding

1. Verify your API key is correct in Roo Code settings
2. Ensure the Base URL is exactly `https://api.tensorx.ai/v1`
3. Check your TensorX credit balance at [app.tensorx.ai](https://app.tensorx.ai/dashboard)

### Context Window Errors

Update the **Context Window** in Model Configuration to match your chosen model. Check [tensorx.ai/models](https://tensorx.ai/models) for current specs.

### Slow Responses

Try switching to a faster model like `minimax/minimax-m2` for simple tasks, or reduce the **Max Output Tokens** setting.

***

## See Also

* [Roo Code Documentation](https://docs.roocode.com/)
* [Roo Code on GitHub](https://github.com/roocodeinc/roo-code)
* [Cline Integration](/ai-coding-assistants/cline) — Similar VS Code extension
* [Kilo Code Integration](/ai-coding-assistants/kilo-code) — Another VS Code coding agent
* [TensorX Models](https://tensorx.ai/models)


# Zed Editor

Use TensorX models as your AI coding assistant in Zed — the high-performance, open-source code editor.

***

## Overview

[Zed](https://zed.dev) is an open-source code editor built for speed, with native AI integration via its Agent Panel. With 76K+ GitHub stars, it's one of the fastest-growing editors. Zed supports OpenAI-compatible providers, making it easy to connect to TensorX models.

{% hint style="success" %}
**Why Zed + TensorX?**

* ⚡ **Blazing fast** — GPU-accelerated editor built in Rust
* 🤖 **Built-in AI Agent** — Inline assistant and Agent Panel
* 🔧 **Tool use** — AI can run terminal commands, edit files, search code
* 💰 **Cost-effective** — Use powerful open-source models instead of expensive proprietary ones
* 👥 **Multiplayer** — Real-time collaboration with AI assistance
  {% endhint %}

***

## Prerequisites

* **Zed** (latest version) — [download here](https://zed.dev/download)
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Setup

### Step 1: Add TensorX as a Provider

1. Open Zed
2. Open the Agent Panel (`Cmd+Shift+A` on macOS / `Ctrl+Shift+A` on Linux)
3. Click **Settings** (gear icon) → **Add Provider**
4. Choose **OpenAI Compatible** and fill in:

| Setting           | Value                       |
| ----------------- | --------------------------- |
| **Provider Name** | `TensorX`                   |
| **API URL**       | `https://api.tensorx.ai/v1` |

### Step 2: Set Your API Key

Set the `TENSORX_API_KEY` environment variable. Zed derives the env var name from the provider name:

```bash
export TENSORX_API_KEY=your-tensorx-api-key-here
```

To make it permanent, add to your `~/.zshrc` or `~/.bashrc`:

```bash
echo 'export TENSORX_API_KEY=your-tensorx-api-key-here' >> ~/.zshrc
```

### Step 3: Configure Models

Alternatively, configure everything via Zed's settings file (`Cmd+,` → Edit `settings.json`):

```json
{
  "language_models": {
    "openai_compatible": {
      "TensorX": {
        "api_url": "https://api.tensorx.ai/v1",
        "available_models": [
          {
            "name": "z-ai/glm-5.1",
            "display_name": "GLM-5.1 ⭐",
            "max_tokens": 203000,
            "max_output_tokens": 16384,
            "capabilities": {
              "tools": true,
              "images": false
            }
          },
          {
            "name": "z-ai/glm-5.2",
            "display_name": "GLM 5.2",
            "max_tokens": 164000,
            "max_output_tokens": 16384,
            "capabilities": {
              "tools": true,
              "images": false
            }
          },
          {
            "name": "deepseek/deepseek-r1-0528",
            "display_name": "DeepSeek R1",
            "max_tokens": 164000,
            "max_output_tokens": 16384,
            "capabilities": {
              "tools": true,
              "images": false
            }
          },
          {
            "name": "minimax/minimax-m2.5",
            "display_name": "MiniMax M2.5",
            "max_tokens": 197000,
            "capabilities": {
              "tools": true,
              "images": false
            }
          },
          {
            "name": "moonshotai/kimi-k2.5",
            "display_name": "Kimi K2.5",
            "max_tokens": 262000,
            "capabilities": {
              "tools": true,
              "images": true
            }
          }
        ]
      }
    }
  }
}
```

### Step 4: Select Model

Open the Agent Panel and select a TensorX model from the model dropdown.

***

## Recommended Models

| Use Case      | Model                       | Why                                      |
| ------------- | --------------------------- | ---------------------------------------- |
| **Coding** ⭐  | `z-ai/glm-5.1`              | Top coding performance, strong reasoning |
| **Reasoning** | `deepseek/deepseek-r1-0528` | Complex analysis, architecture decisions |
| **Functions** | `minimax/minimax-m2.5`      | Function calling, reasoning              |
| **Vision**    | `moonshotai/kimi-k2.5`      | Image understanding, large context       |
| **General**   | `z-ai/glm-5.2`              | Balanced performance and cost            |

***

## Using the AI Features

### Agent Panel

Open with `Cmd+Shift+A` (macOS) / `Ctrl+Shift+A` (Linux). The agent can:

* Write and edit code across multiple files
* Run terminal commands
* Search your codebase
* Explain code and answer questions

### Inline Assistant

Select code and press `Cmd+Enter` (macOS) / `Ctrl+Enter` (Linux) to get inline AI suggestions.

***

## Troubleshooting

### Models Not Appearing

Ensure your `TENSORX_API_KEY` environment variable is set and Zed was restarted after setting it.

### Authentication Errors

The API key env var name is derived from the provider name. If you named your provider "TensorX", the env var must be `TENSORX_API_KEY`.

***

## See Also

* [Zed Documentation](https://zed.dev/docs)
* [Zed LLM Providers](https://zed.dev/docs/ai/llm-providers)
* [Zed on GitHub](https://github.com/zed-industries/zed)
* [TensorX Models](https://tensorx.ai/models)


# Goose

Use TensorX models with Goose — the open-source, on-machine AI agent by Block (Square).

***

## Overview

[Goose](https://block.github.io/goose) is an open-source AI agent built by Block (formerly Square) that runs on your machine and helps with coding, DevOps, and general development tasks. With 32K+ GitHub stars and support for declarative custom providers, it's easy to connect to TensorX.

{% hint style="success" %}
**Why Goose + TensorX?**

* 🪿 **On-machine agent** — Runs locally, full access to your filesystem and tools
* 🔌 **MCP support** — Connect to any tool via Model Context Protocol extensions
* 🖥️ **Desktop + CLI** — Electron desktop app and terminal interface
* 🔒 **Privacy-first** — Your code stays on your machine, EU-hosted models
* 💰 **Cost-effective** — Powerful open-source models at a fraction of the cost
  {% endhint %}

***

## Prerequisites

* **macOS, Linux, or Windows**
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Installation

{% tabs %}
{% tab title="macOS (Homebrew)" %}

```bash
brew install block/tap/goose
```

{% endtab %}

{% tab title="Linux / macOS (curl)" %}

```bash
curl -fsSL https://github.com/block/goose/releases/latest/download/download_cli.sh | bash
```

{% endtab %}

{% tab title="Desktop App" %}
Download from [block.github.io/goose](https://block.github.io/goose)
{% endtab %}
{% endtabs %}

***

## Configuration

### Option 1: Using OpenAI-Compatible Provider

Set environment variables and configure Goose:

```bash
export TENSORX_API_KEY=your-tensorx-api-key-here
```

Then configure via the CLI:

```bash
goose configure
```

When prompted:

1. Choose **OpenAI Compatible** as the provider
2. Enter `https://api.tensorx.ai/v1` as the base URL
3. Enter your model name: `z-ai/glm-5.1`

### Option 2: Settings File

Edit `~/.config/goose/config.yaml`:

```yaml
GOOSE_PROVIDER: openai-compatible
GOOSE_MODEL: z-ai/glm-5.1
OPENAI_BASE_URL: https://api.tensorx.ai/v1
OPENAI_API_KEY: your-tensorx-api-key-here
```

{% hint style="warning" %}
Replace `your-tensorx-api-key-here` with your actual TensorX API key from [app.tensorx.ai](https://app.tensorx.ai/dashboard).
{% endhint %}

***

## Recommended Models

| Use Case      | Model                       | Why                                       |
| ------------- | --------------------------- | ----------------------------------------- |
| **Coding** ⭐  | `z-ai/glm-5.1`              | Best coding performance, strong reasoning |
| **Reasoning** | `deepseek/deepseek-r1-0528` | Complex analysis and planning             |
| **Functions** | `minimax/minimax-m2.5`      | Function calling, reasoning               |
| **Vision**    | `moonshotai/kimi-k2.5`      | Image understanding, large context        |
| **General**   | `z-ai/glm-5.2`              | Balanced performance and cost             |
| **Fast**      | `minimax/minimax-m2`        | Quick responses, cost-sensitive           |

***

## Usage

Start an interactive session:

```bash
goose session
```

Or run a one-shot command:

```bash
goose run "refactor the auth module to use JWT tokens"
```

Goose can:

* Read and edit files in your project
* Run terminal commands
* Search your codebase
* Connect to external tools via MCP extensions

***

## Troubleshooting

### Model Not Responding

1. Verify your API key: `echo $TENSORX_API_KEY`
2. Test the connection:

   ```bash
   curl https://api.tensorx.ai/v1/models \
     -H "Authorization: Bearer $TENSORX_API_KEY"
   ```

### Provider Not Found

Run `goose configure` to reconfigure your provider settings.

***

## See Also

* [Goose Documentation](https://block.github.io/goose)
* [Goose on GitHub](https://github.com/block/goose)
* [Goose Custom Providers](https://github.com/block/goose/blob/main/CUSTOM_DISTROS.md)
* [TensorX Models](https://tensorx.ai/models)


# Aider

[Aider](https://aider.chat/) is an AI pair programming tool that works in your terminal. It integrates with TensorX through its OpenAI-compatible API support.

## Prerequisites

* Aider installed (`pip install aider-chat`)
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

### Environment Variables

Set the following environment variables to connect Aider to TensorX:

```bash
# Mac/Linux
export OPENAI_API_BASE=https://api.tensorx.ai/v1
export OPENAI_API_KEY=your-tensorx-api-key

# Windows (PowerShell)
$env:OPENAI_API_BASE = "https://api.tensorx.ai/v1"
$env:OPENAI_API_KEY = "your-tensorx-api-key"

# Windows (Command Prompt)
setx OPENAI_API_BASE https://api.tensorx.ai/v1
setx OPENAI_API_KEY your-tensorx-api-key
```

### Using with Aider

Navigate to your project directory and start Aider with a TensorX model:

```bash
cd /path/to/your/project

# Use with Claude models via TensorX
aider --model openai/claude-sonnet-4-20250514

# Use with GPT models via TensorX
aider --model openai/gpt-4o
```

The `openai/` prefix tells Aider to use the OpenAI-compatible endpoint.

## Persistent Configuration

You can also set these in a `.env` file in your project directory:

```env
OPENAI_API_BASE=https://api.tensorx.ai/v1
OPENAI_API_KEY=your-tensorx-api-key
```

Or use Aider's YAML configuration file (`.aider.conf.yml`):

```yaml
openai-api-base: https://api.tensorx.ai/v1
openai-api-key: your-tensorx-api-key
model: openai/claude-sonnet-4-20250514
```

## Available Models

Check [TensorX Models](/api-reference/models) for the full list of available models. Popular options include:

| Model                        | Best For                           |
| ---------------------------- | ---------------------------------- |
| `claude-sonnet-4-20250514`   | Complex reasoning, code generation |
| `claude-3-5-sonnet-20241022` | General coding tasks               |
| `gpt-4o`                     | Fast responses, multi-modal        |
| `gpt-4-turbo`                | Large context, document analysis   |

## Troubleshooting

### Empty responses

If you receive empty responses, verify:

1. Your API key is correctly set
2. The base URL includes `/v1` at the end
3. The model name uses the `openai/` prefix

### Model warnings

Aider may show warnings for unfamiliar models. These can be safely ignored as TensorX handles model compatibility.

## Resources

* [Aider Documentation](https://aider.chat/docs/)
* [TensorX API Reference](/api-reference/overview)


# Continue

[Continue](https://continue.dev/) is an open-source AI code assistant for VS Code and JetBrains IDEs. It connects to TensorX through OpenAI-compatible configuration.

## Prerequisites

* Continue extension installed in your IDE
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

### VS Code

1. Open Continue settings by clicking the gear icon in the Continue panel
2. Edit your `config.json` file with the following configuration:

```json
{
  "models": [
    {
      "title": "Claude Sonnet (TensorX)",
      "provider": "openai",
      "model": "claude-sonnet-4-20250514",
      "apiKey": "your-tensorx-api-key",
      "apiBase": "https://api.tensorx.ai/v1"
    },
    {
      "title": "GPT-4o (TensorX)",
      "provider": "openai",
      "model": "gpt-4o",
      "apiKey": "your-tensorx-api-key",
      "apiBase": "https://api.tensorx.ai/v1"
    }
  ],
  "tabAutocompleteModel": {
    "title": "TensorX Autocomplete",
    "provider": "openai",
    "model": "gpt-4o-mini",
    "apiKey": "your-tensorx-api-key",
    "apiBase": "https://api.tensorx.ai/v1"
  }
}
```

### JetBrains IDEs

The configuration is the same for JetBrains IDEs. Access Continue settings through:

1. Open the Continue tool window
2. Click on settings
3. Edit the `config.json` with the configuration above

## Config File Location

The Continue config file is located at:

* **Mac/Linux**: `~/.continue/config.json`
* **Windows**: `%USERPROFILE%\.continue\config.json`

## Multiple Models

You can add multiple TensorX models for different use cases:

```json
{
  "models": [
    {
      "title": "Claude Sonnet 4 (Complex Tasks)",
      "provider": "openai",
      "model": "claude-sonnet-4-20250514",
      "apiKey": "your-tensorx-api-key",
      "apiBase": "https://api.tensorx.ai/v1"
    },
    {
      "title": "Claude 3.5 Haiku (Quick Tasks)",
      "provider": "openai",
      "model": "claude-3-5-haiku-20241022",
      "apiKey": "your-tensorx-api-key",
      "apiBase": "https://api.tensorx.ai/v1"
    },
    {
      "title": "GPT-4o Mini (Fast)",
      "provider": "openai",
      "model": "gpt-4o-mini",
      "apiKey": "your-tensorx-api-key",
      "apiBase": "https://api.tensorx.ai/v1"
    }
  ]
}
```

## Tab Autocomplete

Enable code autocomplete with TensorX:

```json
{
  "tabAutocompleteModel": {
    "title": "TensorX Autocomplete",
    "provider": "openai",
    "model": "gpt-4o-mini",
    "apiKey": "your-tensorx-api-key",
    "apiBase": "https://api.tensorx.ai/v1"
  },
  "tabAutocompleteOptions": {
    "debounceDelay": 500,
    "maxPromptTokens": 1500
  }
}
```

## Available Models

See [TensorX Models](/api-reference/models) for all available models.

## Troubleshooting

### Connection issues

1. Verify your API key is correct
2. Ensure `apiBase` ends with `/v1`
3. Check the Continue output panel for error messages

### Model not working

* Confirm the model name exactly matches TensorX's supported models
* Try a different model to isolate the issue

## Resources

* [Continue Documentation](https://docs.continue.dev/)
* [TensorX API Reference](/api-reference/overview)


# ProxyAI (JetBrains)

Connect [ProxyAI](https://tryproxy.io/) to TensorX and use open-source models directly inside any JetBrains IDE — IntelliJ IDEA, PyCharm, WebStorm, GoLand, and more.

***

## Overview

ProxyAI is an open-source AI coding assistant for JetBrains IDEs. It provides chat, inline editing, AI commit messages, and code completions — all from a single plugin. By pointing ProxyAI's **Custom OpenAI** provider at TensorX, you get access to models like GLM-5.1, MiniMax M2.5, DeepSeek V3.2, and Llama without leaving your IDE.

### What You Can Do

* Chat with AI about your codebase using `@` context (files, folders, docs, git history)
* Inline code editing with natural language instructions
* AI-generated commit messages
* Use personas to tailor AI behaviour for different tasks

***

## Prerequisites

* A JetBrains IDE (IntelliJ IDEA, PyCharm, WebStorm, etc.)
* ProxyAI plugin installed from the [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/21056-codegpt)
* A TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

***

## Setup

### Step 1: Open ProxyAI Provider Settings

1. In your JetBrains IDE, go to **File → Settings** (or **Preferences** on macOS)
2. Navigate to **Tools → ProxyAI → Providers → Custom OpenAI**

### Step 2: Configure Chat Completions

Set up the **Chat Completions** tab with the following:

| Field       | Value                                        |
| ----------- | -------------------------------------------- |
| **URL**     | `https://api.tensorx.ai/v1/chat/completions` |
| **API Key** | Your TensorX API key                         |

In the **Headers** section, ensure these are set:

| Header          | Value                            |
| --------------- | -------------------------------- |
| `Authorization` | `Bearer $CUSTOM_SERVICE_API_KEY` |
| `Content-Type`  | `application/json`               |

In the **Body** section, configure:

| Property      | Type        | Value              |
| ------------- | ----------- | ------------------ |
| `model`       | String      | `z-ai/glm-5.1`     |
| `messages`    | Placeholder | `$OPENAI_MESSAGES` |
| `stream`      | Boolean     | `true`             |
| `temperature` | Number      | `0.1`              |
| `max_tokens`  | Number      | `8192`             |

### Step 3: Test and Save

1. Click the **Test Connection** button to verify the setup
2. Click **Apply** or **OK** to save

***

## Usage

Once configured, you can use TensorX models through ProxyAI's features:

* **Chat**: Open the ProxyAI tool window and start a conversation. Use `@` to reference files, folders, documentation, or git history for context.
* **Inline Edit**: Select code, right-click, and choose ProxyAI's inline edit option to modify code with natural language.
* **AI Commit Messages**: When committing, click the AI icon to generate a commit message based on your staged changes.

***

## Switching Models

To change the model, go back to **Tools → ProxyAI → Providers → Custom OpenAI** and update the `model` value in the Body section.

***

## Recommended Models

| Use Case       | Model                         |
| -------------- | ----------------------------- |
| General / Chat | `z-ai/glm-5.1`                |
| Coding         | `minimax/minimax-m2.5`        |
| Reasoning      | `deepseek/deepseek-r1-0528`   |
| Fast responses | `deepseek/deepseek-v3.2`      |
| Long context   | `meta-llama/llama-4-maverick` |

***

## Note on Code Completions (Autocomplete)

ProxyAI's autocomplete feature uses **fill-in-the-middle (FIM)** — a specialised completion method that requires dedicated infill models. TensorX does not currently offer FIM-capable models, so **autocomplete/tab completions are not supported** at this time.

Chat, inline editing, and all other ProxyAI features work fully with TensorX.

***

## Troubleshooting

| Issue                 | Fix                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------ |
| Connection test fails | Double-check the URL ends with `/v1/chat/completions` (not just `/v1`)                     |
| "Unauthorized" error  | Verify your API key is correct at [app.tensorx.ai](https://app.tensorx.ai)                 |
| No response           | Make sure `stream` is set to `true` and `messages` uses the `$OPENAI_MESSAGES` placeholder |
| Model not found       | Check the model name matches exactly (e.g. `z-ai/glm-5.2`, not just `deepseek`)            |

***

## See Also

* [Quickstart](/quickstart)
* [Chat Completions API](/api-reference/chat-completions)
* [Models](/api-reference/models)


# OpenCode

Use TensorX models with [OpenCode](https://opencode.ai), the open-source terminal-based AI coding agent.

***

## Prerequisites

* [OpenCode](https://opencode.ai) installed
* A TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

***

## Configuration

### Step 1: Connect the Provider

Run `/connect` in OpenCode, select **Other**, and enter:

| Field       | Value                |
| ----------- | -------------------- |
| Provider ID | `tensorx`            |
| API Key     | Your TensorX API key |

### Step 2: Configure opencode.json

Add the following to your project's `opencode.json` (or `~/.opencode/opencode.json` for global config):

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "tensorx": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "TensorX",
      "options": {
        "baseURL": "https://api.tensorx.ai/v1",
        "apiKey": "{env:TENSORX_API_KEY}"
      },
      "models": {
        "z-ai/glm-5.1": {
          "name": "GLM 5.1",
          "limit": {
            "context": 131072,
            "output": 16384
          }
        },
        "moonshotai/kimi-k2.5": {
          "name": "Kimi K2.5",
          "limit": {
            "context": 131072,
            "output": 16384
          }
        },
        "deepseek/deepseek-r1-0528": {
          "name": "DeepSeek R1",
          "limit": {
            "context": 131072,
            "output": 16384
          }
        }
      }
    }
  }
}
```

### Step 3: Set API Key

Set your API key as an environment variable:

```bash
export TENSORX_API_KEY=your-tensorx-api-key-here
```

Or add to `~/.opencode/.env`:

```
TENSORX_API_KEY=your-tensorx-api-key-here
```

***

## Vision / Image Support

{% hint style="warning" %}
**Important:** To use vision-capable models (e.g. Kimi K2.5, Kimi K3) with image attachments, you **must** add `modalities` to the model config. Without this, OpenCode will strip images before sending them.
{% endhint %}

```json
"moonshotai/kimi-k2.5": {
  "name": "Kimi K2.5",
  "modalities": {
    "input": ["text", "image"],
    "output": ["text"]
  }
},
"moonshotai/kimi-k3": {
  "name": "Kimi K3",
  "modalities": {
    "input": ["text", "image"],
    "output": ["text"]
  }
}
```

***

## Available Models

| Model       | ID                          | Best For           |
| ----------- | --------------------------- | ------------------ |
| GLM 5.1     | `z-ai/glm-5.1`              | General, Tool Use  |
| Kimi K2.5   | `moonshotai/kimi-k2.5`      | Reasoning, Vision  |
| Kimi K3     | `moonshotai/kimi-k3`        | Vision, Multimodal |
| DeepSeek R1 | `deepseek/deepseek-r1-0528` | Reasoning, Code    |
| MiniMax M2  | `minimax/minimax-m2`        | Long Context       |

***

## Tips

* **GLM 5.1** is recommended for tool-heavy coding workflows
* For vision tasks, remember to add the `modalities` config shown above
* You can add any model from the [TensorX model catalog](https://tensorx.ai/models) — use the model ID as the key

## Resources

* [OpenCode Documentation](https://opencode.ai)
* [TensorX API Reference](https://docs.tensorx.ai)
* [TensorX Model Catalog](https://tensorx.ai/models)


# OpenClaw

Connect OpenClaw to TensorX.ai and run a privacy-focused AI assistant on WhatsApp, Telegram, Discord, iMessage, and more — powered by open-source models.

***

## What is OpenClaw?

[OpenClaw](https://openclaw.ai) is an open-source, self-hosted AI agent gateway that connects AI models to your favorite messaging platforms. By configuring TensorX as a custom provider, you can run powerful open-source models like GLM-5.1, MiniMax, and DeepSeek across all your chat channels.

{% hint style="success" %}
**Why OpenClaw + TensorX?**

* 🔒 **Privacy-first** — Self-hosted gateway + EU-hosted models with zero data retention
* 💰 **Cost-effective** — 50–70% cheaper than Claude
* 📱 **Multi-platform** — WhatsApp, Telegram, Discord, Slack, iMessage, Signal, and more
* 🤖 **Multiple models** — Choose from GLM-5.1, MiniMax, DeepSeek, Kimi, and others
* 🛡️ **Secure** — Pairing system prevents unauthorized access
* 🌐 **Control UI** — Browser dashboard for chat, config, and session management
  {% endhint %}

***

## Prerequisites

* **Node.js** >= 22 ([download here](https://nodejs.org/))
* **macOS, Linux, or Windows** (PowerShell installer available)
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Installation

### Step 1: Install OpenClaw

{% tabs %}
{% tab title="macOS / Linux / WSL2" %}

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```

{% endtab %}

{% tab title="Windows (PowerShell)" %}

```powershell
iwr -useb https://openclaw.ai/install.ps1 | iex
```

{% endtab %}

{% tab title="npm" %}

```bash
npm install -g openclaw@latest
```

{% endtab %}
{% endtabs %}

Verify installation:

```bash
openclaw --version
```

***

## Configuration

### Step 2: Run the Onboarding Wizard

```bash
openclaw onboard --install-daemon
```

The wizard guides you through auth, gateway settings, and optional channels. Accept the defaults to get started quickly.

### Step 3: Configure TensorX as a Custom Provider

OpenClaw uses a JSON5 config file at `~/.openclaw/openclaw.json`. Add TensorX as a custom provider:

```json5
// ~/.openclaw/openclaw.json
{
  models: {
    providers: {
      tensorx: {
        api: "openai-completions",
        baseUrl: "https://api.tensorx.ai/v1",
        apiKey: "${TENSORX_API_KEY}",
      }
    }
  },
  agents: {
    defaults: {
      model: "tensorx/z-ai/glm-5.1",
      models: {
        "tensorx/z-ai/glm-5.1": { alias: "glm" },
        "tensorx/z-ai/glm-5.2": { alias: "deepseek" },
        "tensorx/deepseek/deepseek-r1-0528": { alias: "r1" },
        "tensorx/minimax/minimax-m2.5": { alias: "minimax" },
        "tensorx/moonshotai/kimi-k2.5": { alias: "kimi" },
      }
    }
  }
}
```

{% hint style="warning" %}
**Override the default base URL.** OpenClaw points at `api.z.ai` out of the box. The `baseUrl: "https://api.tensorx.ai/v1"` line above overrides that default — make sure it is set so requests reach TensorX rather than the default endpoint.
{% endhint %}

Then set your API key in `~/.openclaw/.env`:

```bash
echo 'TENSORX_API_KEY=your-tensorx-api-key-here' >> ~/.openclaw/.env
```

{% hint style="warning" %}
**Important:** Replace `your-tensorx-api-key-here` with your actual TensorX API key from [app.tensorx.ai](https://app.tensorx.ai/dashboard).
{% endhint %}

### Step 4: Restart the Gateway

```bash
openclaw gateway restart
```

### Step 5: Verify Setup

```bash
# Check gateway status
openclaw gateway status

# Open the Control UI in your browser
openclaw dashboard
```

The Control UI opens at `http://127.0.0.1:18789/`. Send a test message to verify the connection.

***

## Recommended Models

OpenClaw works with all TensorX models. Switch models in chat with `/model <alias>` or update `agents.defaults.model` in config.

| Model                       | Alias      | Best For                       |
| --------------------------- | ---------- | ------------------------------ |
| `z-ai/glm-5.1` ⭐            | `glm`      | Coding, reasoning, general use |
| `minimax/minimax-m2.5`      | `minimax`  | Reasoning, function calling    |
| `moonshotai/kimi-k2.5`      | `kimi`     | Vision, long context           |
| `minimax/minimax-m2`        | —          | Fast responses, cost-sensitive |
| `z-ai/glm-5.2`              | `deepseek` | General chat, balanced         |
| `deepseek/deepseek-r1-0528` | `r1`       | Complex reasoning tasks        |

***

## Adding Chat Channels

OpenClaw supports WhatsApp, Telegram, Discord, Slack, iMessage, Signal, Google Chat, Mattermost, MS Teams, IRC, and more.

### WhatsApp

```bash
openclaw channels login
```

Scan the QR code in **WhatsApp → Settings → Linked Devices**, then approve the pairing:

```bash
openclaw pairing approve whatsapp WA-XXXXX
```

### Telegram

1. Create a bot via [@BotFather](https://t.me/BotFather) and copy the bot token
2. Add to `~/.openclaw/.env`:

   ```bash
   TELEGRAM_BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
   ```
3. Restart and approve pairing:

   ```bash
   openclaw gateway restart
   openclaw pairing approve telegram TG-XXXXX
   ```

### Discord

1. Create a bot at the [Discord Developer Portal](https://discord.com/developers/applications) and copy the token
2. Add to `~/.openclaw/.env`:

   ```bash
   DISCORD_BOT_TOKEN=your_discord_bot_token_here
   ```
3. Restart the gateway:

   ```bash
   openclaw gateway restart
   ```

{% hint style="info" %}
See the [OpenClaw channels documentation](https://docs.openclaw.ai/channels/telegram) for setup guides for all supported platforms.
{% endhint %}

***

## Multi-Agent Routing

Run multiple agents with different models for different purposes:

```json5
// ~/.openclaw/openclaw.json
{
  agents: {
    list: [
      { id: "coder", model: "tensorx/z-ai/glm-5.1", default: true },
      { id: "thinker", model: "tensorx/deepseek/deepseek-r1-0528" },
    ],
    defaults: {
      // ... provider config from above
    }
  },
  bindings: [
    { match: { channel: "telegram" }, agent: "thinker" },
    { match: { channel: "whatsapp" }, agent: "coder" },
  ]
}
```

***

## Common Commands

```bash
# Gateway
openclaw gateway status           # Check status
openclaw gateway start            # Start gateway
openclaw gateway stop             # Stop gateway
openclaw gateway restart          # Restart gateway
openclaw dashboard                # Open Control UI
openclaw doctor                   # Diagnose issues

# Channels & Pairing
openclaw channels login                       # Connect a channel
openclaw pairing list                         # List pending pairings
openclaw pairing approve <channel> <code>     # Approve pairing

# Configuration
openclaw configure                # Interactive config wizard
openclaw config get <key>         # Read a config value
openclaw config set <key> <val>   # Set a config value
```

***

## Troubleshooting

### Gateway Won't Start

```bash
# Check if the port is in use
lsof -i :18789

# Run diagnostics
openclaw doctor
```

### No Response from Model

1. Verify your TensorX API key works:

   ```bash
   curl https://api.tensorx.ai/v1/models \
     -H "Authorization: Bearer YOUR_TENSORX_KEY"
   ```
2. Check your config for typos:

   ```bash
   openclaw config get models.providers.tensorx
   ```
3. Restart the gateway:

   ```bash
   openclaw gateway restart
   ```

### Channel Not Working

```bash
# Check gateway logs
openclaw logs

# Verify channel status
openclaw channels status
```

***

## Cost Optimization

| Use Case         | Recommended Model           | Why                                 |
| ---------------- | --------------------------- | ----------------------------------- |
| Simple questions | `minimax/minimax-m2`        | Fast and cheap                      |
| Coding tasks     | `z-ai/glm-5.1`              | Best coding performance             |
| Deep reasoning   | `deepseek/deepseek-r1-0528` | Worth the cost for complex problems |
| General chat     | `z-ai/glm-5.2`              | Balanced performance and cost       |
| Vision tasks     | `moonshotai/kimi-k2.5`      | Image understanding, long context   |

Use OpenClaw's pairing system to prevent unauthorized usage that would consume your credits.

***

## Resources

* **OpenClaw Documentation:** [docs.openclaw.ai](https://docs.openclaw.ai/)
* **OpenClaw GitHub:** [github.com/openclaw/openclaw](https://github.com/openclaw/openclaw)
* **TensorX Models:** [tensorx.ai/models](https://tensorx.ai/models)
* **TensorX Dashboard:** [app.tensorx.ai](https://app.tensorx.ai/dashboard)

***

## FAQ

**Q: Do I need an Anthropic or OpenAI account?**

No! TensorX provides all the models you need. You only need a TensorX API key.

**Q: Can I switch between models on the fly?**

Yes! Use `/model <alias>` in any chat to switch models mid-conversation (e.g., `/model r1` for reasoning tasks).

**Q: Can I switch back to Claude or another provider later?**

Yes. Update the `models.providers` section in `~/.openclaw/openclaw.json` to point to a different provider, or add multiple providers and switch between them.

**Q: Which model should I start with?**

We recommend `z-ai/glm-5.1` for most use cases. It offers excellent coding capabilities, strong reasoning, and good general performance.

***

**Need help?** Contact <support@tensorx.ai> or check the [OpenClaw documentation](https://docs.openclaw.ai/).


# Agent Zero

Build autonomous AI agents powered by TensorX models using Agent Zero — the open-source agentic AI framework.

***

## Overview

[Agent Zero](https://agent-zero.ai) is an open-source autonomous AI agent framework that can operate on its own computer, create and use tools, learn from experience, and execute complex workflows. Agent Zero uses LiteLLM under the hood, making it easy to connect to TensorX as a custom provider.

{% hint style="success" %}
**Why Agent Zero + TensorX?**

* 🧠 **Autonomous agents** — Self-correcting AI that creates its own tools
* 🔒 **Privacy-first** — Self-hosted framework + EU-hosted models with zero data retention
* 🌐 **Web UI** — Built-in browser-based interface for managing agents
* 🔧 **Tool creation** — Agents dynamically create and use tools as needed
* 💰 **Cost-effective** — Run complex agent workflows at a fraction of the cost
  {% endhint %}

***

## Prerequisites

* **Python** 3.10+ and **Node.js** 22+
* **Docker** (recommended for sandboxed execution)
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Installation

```bash
git clone https://github.com/agent0ai/agent-zero.git
cd agent-zero
pip install -r requirements.txt
```

***

## Configuration

### Option 1: Web UI Setup

1. Start Agent Zero:

   ```bash
   python run_ui.py
   ```
2. Open `http://localhost:50001` in your browser
3. Go to **Settings** and configure:

| Setting                 | Value                       |
| ----------------------- | --------------------------- |
| **Chat Model Provider** | `Other OpenAI compatible`   |
| **Chat Model Name**     | `z-ai/glm-5.1`              |
| **Chat Model API Key**  | Your TensorX API key        |
| **Chat Model API Base** | `https://api.tensorx.ai/v1` |

4. Set the same for **Utility Model** (or use a faster model like `minimax/minimax-m2`)

### Option 2: Environment Variables

Create a `.env` file in the Agent Zero root directory:

```bash
# Chat model (main agent)
CHAT_MODEL_PROVIDER=other
CHAT_MODEL_NAME=z-ai/glm-5.1
API_KEY_OTHER=your-tensorx-api-key-here
CHAT_MODEL_API_BASE=https://api.tensorx.ai/v1

# Utility model (background tasks)
UTILITY_MODEL_PROVIDER=other
UTILITY_MODEL_NAME=minimax/minimax-m2
UTILITY_MODEL_API_BASE=https://api.tensorx.ai/v1
```

{% hint style="warning" %}
Replace `your-tensorx-api-key-here` with your actual TensorX API key from [app.tensorx.ai](https://app.tensorx.ai/dashboard).
{% endhint %}

***

## Recommended Models

| Use Case              | Model                       | Why                                 |
| --------------------- | --------------------------- | ----------------------------------- |
| **Chat model** ⭐      | `z-ai/glm-5.1`              | Best coding + reasoning performance |
| **Utility model**     | `minimax/minimax-m2`        | Fast, cheap for background tasks    |
| **Complex reasoning** | `deepseek/deepseek-r1-0528` | Deep analysis and planning          |
| **Vision tasks**      | `moonshotai/kimi-k2.5`      | Image understanding, large context  |
| **General chat**      | `z-ai/glm-5.2`              | Balanced performance and cost       |

***

## Usage

Start the web UI and interact with your agent:

```bash
python run_ui.py
```

Agent Zero will autonomously:

* Break down complex tasks into steps
* Create and execute tools
* Search the web for information
* Write and run code
* Self-correct when errors occur

***

## Troubleshooting

### Agent Not Responding

1. Check your API key and base URL in Settings
2. Verify your TensorX credit balance at [app.tensorx.ai](https://app.tensorx.ai/dashboard)
3. Check the terminal logs for error messages

### Tool Execution Errors

Ensure Docker is running if you're using sandboxed execution mode.

***

## See Also

* [Agent Zero Documentation](https://agent-zero.ai/p/docs/get-started/)
* [Agent Zero GitHub](https://github.com/agent0ai/agent-zero)
* [TensorX Models](https://tensorx.ai/models)


# Hermes Agent

Use TensorX models with Hermes Agent — the self-improving AI agent by Nous Research.

***

## Overview

[Hermes Agent](https://github.com/NousResearch/hermes-agent) is an open-source AI agent built by [Nous Research](https://nousresearch.com) that learns from experience, creates skills autonomously, and works across CLI, Telegram, Discord, Slack, and WhatsApp. It supports custom OpenAI-compatible endpoints via environment variables or config.

{% hint style="success" %}
**Why Hermes Agent + TensorX?**

* 🧠 **Self-improving** — Creates and refines skills from experience
* 📱 **Multi-platform** — CLI, Telegram, Discord, Slack, WhatsApp gateway
* 🔄 **Learning loop** — Agent-curated memory with cross-session recall
* ⏰ **Scheduled tasks** — Built-in cron scheduler with natural language
* 🔒 **Privacy-first** — Self-hosted agent + EU-hosted models
  {% endhint %}

***

## Prerequisites

* **Linux, macOS, or WSL2** (native Windows not supported)
* **Git**
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Installation

```bash
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
source ~/.bashrc
```

***

## Configuration

### Option 1: Setup Wizard

```bash
hermes setup
```

When prompted for provider, choose **Custom/OpenAI-compatible** and enter:

| Setting      | Value                       |
| ------------ | --------------------------- |
| **Base URL** | `https://api.tensorx.ai/v1` |
| **API Key**  | Your TensorX API key        |
| **Model**    | `z-ai/glm-5.1`              |

### Option 2: Environment Variables

```bash
export OPENAI_BASE_URL=https://api.tensorx.ai/v1
export OPENAI_API_KEY=your-tensorx-api-key-here
```

To make permanent, add to `~/.bashrc` or `~/.zshrc`.

### Option 3: Config File

Edit `~/.hermes/config.yaml`:

```yaml
model:
  provider: auto
  default: z-ai/glm-5.1
  base_url: https://api.tensorx.ai/v1
```

{% hint style="warning" %}
Replace `your-tensorx-api-key-here` with your actual TensorX API key from [app.tensorx.ai](https://app.tensorx.ai/dashboard).
{% endhint %}

***

## Usage

```bash
hermes                  # Start interactive CLI
hermes model            # Switch model
hermes gateway          # Start messaging gateway (Telegram, Discord, etc.)
hermes doctor           # Diagnose issues
```

***

## Recommended Models

| Use Case          | Model                       | Why                               |
| ----------------- | --------------------------- | --------------------------------- |
| **General use** ⭐ | `z-ai/glm-5.1`              | Coding, reasoning, skill creation |
| **Reasoning**     | `deepseek/deepseek-r1-0528` | Complex analysis, planning        |
| **Balanced**      | `z-ai/glm-5.2`              | Good all-round performance        |
| **Fast tasks**    | `minimax/minimax-m2`        | Quick responses, background tasks |
| **Long context**  | `moonshotai/kimi-k2.5`      | Large context, vision support     |

***

## Messaging Gateway

Connect your agent to messaging platforms:

```bash
hermes gateway
```

Hermes Agent supports Telegram, Discord, Slack, and WhatsApp — all from a single gateway process with cross-platform conversation continuity.

***

## Troubleshooting

### Agent Not Responding

1. Verify your environment variables:

   ```bash
   echo $OPENAI_BASE_URL
   echo $OPENAI_API_KEY
   ```
2. Run diagnostics:

   ```bash
   hermes doctor
   ```

### Model Errors

Switch models with:

```bash
hermes model
```

***

## See Also

* [Hermes Agent GitHub](https://github.com/NousResearch/hermes-agent)
* [Nous Research](https://nousresearch.com)
* [TensorX Models](https://tensorx.ai/models)


# LibreChat

Connect LibreChat to TensorX.ai and access leading open-source models like DeepSeek, Llama, Qwen, and GLM through a single self-hosted interface.

***

## What is LibreChat?

[LibreChat](https://www.librechat.ai/) is an open-source ChatGPT alternative that supports multiple AI providers through OpenAI-compatible APIs. With TensorX, you get a privacy-focused, self-hosted chat interface with access to all our models.

{% hint style="success" %}
**Why LibreChat + TensorX?**

* 🔒 **Self-hosted** - Your conversations stay on your infrastructure
* 🌍 **EU-hosted models** - Privacy-focused European hosting
* 🚀 **Multiple models** - DeepSeek, Llama, Qwen, GLM, and more
* 💰 **Simple pricing** - One API key, transparent costs
  {% endhint %}

***

## Prerequisites

* LibreChat installed and running (follow the [official LibreChat installation guide](https://www.librechat.ai/docs/configuration/docker_override))
* A TensorX API key ([sign up here](https://app.tensorx.ai))

***

## Configuration

### Step 1: Add Your API Key

Add your TensorX API key to LibreChat's `.env` file:

```bash
TENSORX_API_KEY=your-tensorx-api-key-here
```

### Step 2: Configure the TensorX Endpoint

Create or edit your `librechat.yaml` file:

```yaml
version: 1.1.7
cache: true

endpoints:
  custom:
    - name: "TensorX AI"
      apiKey: "${TENSORX_API_KEY}"
      baseURL: "https://api.tensorx.ai/v1"
      models:
        default:
          - "z-ai/glm-5.2"
          - "deepseek/deepseek-r1-0528"
          - "z-ai/glm-5.1"
          - "meta-llama/llama-3.3-70b-instruct"
          - "meta-llama/llama-4-maverick"
          - "qwen/qwen3-235b-a22b-2507"
          - "z-ai/glm-5.2"
          - "minimax/minimax-m2.5"
        fetch: false
      titleConvo: true
      titleModel: "z-ai/glm-5.2"
      summarize: false
      summaryModel: "z-ai/glm-5.2"
      forcePrompt: false
      modelDisplayLabel: "TensorX AI"
      dropParams: ["user"]
```

### Step 3: Mount the Configuration

Add this to your `docker-compose.override.yml`:

```yaml
services:
  api:
    volumes:
      - ./librechat.yaml:/app/librechat.yaml:ro
```

### Step 4: Restart LibreChat

```bash
docker compose restart api
```

***

## Using TensorX in LibreChat

1. Open LibreChat in your browser
2. Start a new conversation
3. Click the model selector dropdown
4. Select **TensorX AI** as the provider
5. Choose your preferred model

***

## Available Models

| Model                         | Features             | Best For                       |
| ----------------------------- | -------------------- | ------------------------------ |
| `z-ai/glm-5.1` ⭐              | Functions, Reasoning | Coding, reasoning, general use |
| `minimax/minimax-m2.5`        | Functions, Reasoning | Reasoning, general purpose     |
| `moonshotai/kimi-k2.5`        | Vision, Functions    | Vision, long context           |
| `z-ai/glm-5.2`                | Functions, Reasoning | General chat, fast reasoning   |
| `deepseek/deepseek-r1-0528`   | Functions, Reasoning | Complex reasoning tasks        |
| `minimax/minimax-m2`          | Coding, Functions    | Coding, fast responses         |
| `meta-llama/llama-4-maverick` | Functions            | Long context, multimodal       |
| `z-ai/glm-5.2`                | Functions, Reasoning | GPT-4 alternative              |

{% hint style="info" %}
**View full model list and pricing**: [tensorx.ai/models](https://tensorx.ai/models)
{% endhint %}

***

## Model Recommendations

| Task                  | Recommended Models                                    |
| --------------------- | ----------------------------------------------------- |
| **General chat**      | `z-ai/glm-5.2`, `meta-llama/llama-3.3-70b-instruct`   |
| **Complex reasoning** | `deepseek/deepseek-r1-0528`, `z-ai/glm-5.2`           |
| **Coding**            | `z-ai/glm-5.1`, `minimax/minimax-m2`                  |
| **Vision tasks**      | `moonshotai/kimi-k2.5`, `meta-llama/llama-4-maverick` |
| **Multilingual**      | `z-ai/glm-5.1`                                        |

***

## Advanced Configuration

### Auto-Fetch All Models

To automatically discover all available TensorX models:

```yaml
models:
  fetch: true
  default:
    - "z-ai/glm-5.2"
```

### Custom Parameters

```yaml
endpoints:
  custom:
    - name: "TensorX AI"
      apiKey: "${TENSORX_API_KEY}"
      baseURL: "https://api.tensorx.ai/v1"
      models:
        default:
          - "z-ai/glm-5.2"
        fetch: false
      default: ["max_tokens", "temperature", "top_p"]
      additionalParameters:
        max_tokens: 4000
        temperature: 0.7
        top_p: 0.9
```

### Organize by Category

Create multiple endpoints for different model types:

```yaml
endpoints:
  custom:
    - name: "TensorX - Reasoning"
      apiKey: "${TENSORX_API_KEY}"
      baseURL: "https://api.tensorx.ai/v1"
      models:
        default:
          - "deepseek/deepseek-r1-0528"
          - "z-ai/glm-5.2"
    
    - name: "TensorX - General"
      apiKey: "${TENSORX_API_KEY}"
      baseURL: "https://api.tensorx.ai/v1"
      models:
        default:
          - "meta-llama/llama-3.3-70b-instruct"
          - "z-ai/glm-5.1"
```

***

## Configuration Options

| Option           | Description                                        |
| ---------------- | -------------------------------------------------- |
| `apiKey`         | Your TensorX API key from environment variables    |
| `baseURL`        | TensorX API endpoint (`https://api.tensorx.ai/v1`) |
| `models.default` | List of models shown in the dropdown               |
| `fetch`          | Set `true` to auto-fetch available models          |
| `titleConvo`     | Auto-generate conversation titles                  |
| `titleModel`     | Model used for titles (use a fast model)           |
| `dropParams`     | Remove parameters that may cause issues            |

***

## Troubleshooting

### Models Not Appearing

1. Verify your API key is set in `.env`
2. Check that `librechat.yaml` is properly mounted
3. Restart the API container: `docker compose restart api`
4. Check logs: `docker compose logs api`

### Test Your API Key

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
```

### Configuration Not Loading

* Use proper YAML indentation (2 spaces)
* Verify quotes around strings
* Check version number matches your LibreChat version

***

## Best Practices

1. **Use fast models for titles** - Set `titleModel` to `z-ai/glm-5.2`
2. **Limit your model list** - Only include models you actually use
3. **Secure your API key** - Never commit `.env` files to version control
4. **Monitor usage** - Track API usage in your [TensorX dashboard](https://app.tensorx.ai/dashboard)

***

## Resources

* [LibreChat Documentation](https://www.librechat.ai/docs)
* [LibreChat Custom Endpoints Guide](https://www.librechat.ai/docs/configuration/librechat_yaml/ai_endpoints/custom)
* [TensorX Models & Pricing](https://tensorx.ai/models)
* [TensorX API Examples](/api-reference/api-examples)

***

## Need Help?

* 📧 **Email**: <support@tensorx.ai>
* 💬 **Contact Support**: [Contact page](/support/support)


# Open WebUI

Connect Open WebUI to TensorX.ai and get a feature-rich, self-hosted ChatGPT-style interface with access to all our models.

***

## What is Open WebUI?

[Open WebUI](https://openwebui.com/) is an open-source, self-hosted ChatGPT alternative with a beautiful interface and powerful features. With TensorX, you get automatic model discovery - all models are instantly available.

{% hint style="success" %}
**Why Open WebUI + TensorX?**

* 🔒 **Self-hosted** - Your conversations stay on your infrastructure
* 🌍 **EU-hosted models** - Privacy-focused European hosting
* 🔄 **Auto-discovery** - All TensorX models automatically available
* 📁 **Document chat** - Upload and chat with your files
* 👥 **Multi-user** - Create accounts for your team
  {% endhint %}

***

## Prerequisites

* Docker installed on your system
* A TensorX API key ([sign up here](https://app.tensorx.ai))
* At least 2GB RAM and 10GB disk space
* Port 8080 available

***

## Quick Start

Deploy Open WebUI with TensorX in **one command**:

```bash
docker run -d \
  --name open-webui \
  --restart always \
  -p 8080:8080 \
  -e OPENAI_API_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_API_KEY=your-tensorx-api-key-here \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main
```

{% hint style="warning" %}
**Replace** `your-tensorx-api-key-here` with your actual TensorX API key!
{% endhint %}

Then open `http://localhost:8080` in your browser.

***

## Setup Guide

### Step 1: Deploy Open WebUI

```bash
docker run -d \
  --name open-webui \
  --restart always \
  -p 8080:8080 \
  -e ENABLE_SIGNUP=true \
  -e WEBUI_AUTH=true \
  -e OPENAI_API_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_API_KEY=your-tensorx-api-key-here \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main
```

### Step 2: Access Open WebUI

Open your browser and navigate to:

```
http://localhost:8080
```

Or if running on a server: `http://YOUR_SERVER_IP:8080`

### Step 3: Create Your Admin Account

1. On first visit, you'll see a signup form
2. **The first user to sign up automatically becomes admin**
3. Enter your name, email, and a strong password
4. Click **Sign Up**

### Step 4: Start Chatting

1. All TensorX models are automatically available
2. Click the model selector dropdown at the top
3. Choose any model and start chatting!

***

## Available Models

Open WebUI automatically discovers all models from your TensorX API.

| Model                         | Features             | Best For                       |
| ----------------------------- | -------------------- | ------------------------------ |
| `z-ai/glm-5.1` ⭐              | Functions, Reasoning | Coding, reasoning, general use |
| `minimax/minimax-m2.5`        | Functions, Reasoning | Reasoning, general purpose     |
| `moonshotai/kimi-k2.5`        | Vision, Functions    | Vision, long context           |
| `z-ai/glm-5.2`                | Functions, Reasoning | General chat, fast reasoning   |
| `deepseek/deepseek-r1-0528`   | Functions, Reasoning | Complex reasoning tasks        |
| `minimax/minimax-m2`          | Coding, Functions    | Coding, fast responses         |
| `meta-llama/llama-4-maverick` | Functions            | Long context, multimodal       |
| `z-ai/glm-5.2`                | Functions, Reasoning | GPT-4 alternative              |

{% hint style="info" %}
**View full model list and pricing**: [tensorx.ai/models](https://tensorx.ai/models)
{% endhint %}

***

## Model Recommendations

| Task                  | Recommended Models                                    |
| --------------------- | ----------------------------------------------------- |
| **General chat**      | `z-ai/glm-5.2`, `meta-llama/llama-3.3-70b-instruct`   |
| **Complex reasoning** | `deepseek/deepseek-r1-0528`, `z-ai/glm-5.2`           |
| **Coding**            | `z-ai/glm-5.1`, `minimax/minimax-m2`                  |
| **Vision tasks**      | `moonshotai/kimi-k2.5`, `meta-llama/llama-4-maverick` |
| **Long context**      | `moonshotai/kimi-k2.5`, `meta-llama/llama-4-maverick` |
| **Multilingual**      | `z-ai/glm-5.1`                                        |

***

## Features

Open WebUI includes powerful features out of the box:

* 📁 **Document Upload** - Chat with PDFs, docs, and more
* 🔍 **Web Search** - Real-time web search integration
* 💾 **Conversation History** - All chats saved automatically
* 📂 **Folders** - Organize your conversations
* ⚙️ **Model Parameters** - Adjust temperature, top\_p, etc.
* 👥 **Multi-User Support** - Create accounts for your team
* 🔌 **API Access** - Use Open WebUI as an API gateway

***

## Docker Compose Setup

For easier management, create a `docker-compose.yml`:

```yaml
version: '3.8'

services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: always
    ports:
      - "8080:8080"
    environment:
      - OPENAI_API_BASE_URL=https://api.tensorx.ai/v1
      - OPENAI_API_KEY=your-tensorx-api-key-here
      - ENABLE_SIGNUP=true
      - WEBUI_AUTH=true
      - DEFAULT_USER_ROLE=user
    volumes:
      - open-webui:/app/backend/data

volumes:
  open-webui:
```

Deploy with:

```bash
docker compose up -d
```

***

## Configuration Options

### Change Port

Use port 3000 instead of 8080:

```bash
docker run -d \
  --name open-webui \
  -p 3000:8080 \
  -e OPENAI_API_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_API_KEY=your-api-key \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main
```

### Disable Signups (After Creating Admin)

```bash
docker stop open-webui && docker rm open-webui

docker run -d \
  --name open-webui \
  -p 8080:8080 \
  -e ENABLE_SIGNUP=false \
  -e OPENAI_API_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_API_KEY=your-api-key \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main
```

### Enable All Features

```bash
docker run -d \
  --name open-webui \
  --restart always \
  -p 8080:8080 \
  -e OPENAI_API_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_API_KEY=your-tensorx-api-key \
  -e ENABLE_SIGNUP=true \
  -e WEBUI_AUTH=true \
  -e ENABLE_API_KEY=true \
  -e ENABLE_IMAGE_GENERATION=true \
  -e ENABLE_RAG_WEB_SEARCH=true \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main
```

***

## Environment Variables

| Variable                | Default | Description                 |
| ----------------------- | ------- | --------------------------- |
| `OPENAI_API_BASE_URL`   | -       | `https://api.tensorx.ai/v1` |
| `OPENAI_API_KEY`        | -       | Your TensorX API key        |
| `ENABLE_SIGNUP`         | `true`  | Allow new user registration |
| `WEBUI_AUTH`            | `true`  | Enable authentication       |
| `DEFAULT_USER_ROLE`     | `user`  | Default role for new users  |
| `ENABLE_API_KEY`        | `false` | Enable API key generation   |
| `ENABLE_RAG_WEB_SEARCH` | `false` | Enable web search           |

***

## Maintenance

### Update Open WebUI

```bash
docker pull ghcr.io/open-webui/open-webui:main
docker stop open-webui && docker rm open-webui

docker run -d \
  --name open-webui \
  -p 8080:8080 \
  -e OPENAI_API_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_API_KEY=your-api-key \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main
```

Your data persists in the Docker volume.

### Backup Data

```bash
docker run --rm \
  -v open-webui:/data \
  -v $(pwd):/backup \
  alpine tar czf /backup/open-webui-backup-$(date +%Y%m%d).tar.gz /data
```

***

## Troubleshooting

### Models Not Loading

1. Check your API key is correct
2. Verify base URL: `https://api.tensorx.ai/v1`
3. Restart: `docker restart open-webui`
4. Check logs: `docker logs open-webui`

### Test Your API Key

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
```

### Update API Key

```bash
docker stop open-webui && docker rm open-webui

docker run -d \
  --name open-webui \
  -p 8080:8080 \
  -e OPENAI_API_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_API_KEY=your-new-api-key \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main
```

### Check Logs

```bash
docker logs open-webui
docker logs -f open-webui  # Follow in real-time
```

***

## Security Best Practices

1. **Disable signup** after creating admin: `ENABLE_SIGNUP=false`
2. **Use strong passwords** for all accounts
3. **Enable HTTPS** via reverse proxy (nginx/Caddy)
4. **Keep updated** - pull latest images regularly
5. **Backup regularly** - schedule automatic backups
6. **Firewall** - only expose to trusted networks

***

## Resources

* [Open WebUI Documentation](https://docs.openwebui.com/)
* [Open WebUI GitHub](https://github.com/open-webui/open-webui)
* [TensorX Models & Pricing](https://tensorx.ai/models)
* [TensorX API Examples](/api-reference/api-examples)

***

## Need Help?

* 📧 **Email**: <support@tensorx.ai>
* 💬 **Contact Support**: [Contact page](/support/support)


# LobeChat

[LobeChat](https://lobehub.com/) is an open-source, modern-design ChatGPT/LLM UI. Connect it to TensorX using the OpenAI-compatible configuration.

## Prerequisites

* LobeChat installed (self-hosted or local)
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration Options

### Option 1: Environment Variables (Recommended for Self-Hosted)

Set these environment variables when deploying LobeChat:

```bash
# Required
OPENAI_API_KEY=your-tensorx-api-key
OPENAI_PROXY_URL=https://api.tensorx.ai/v1

# Optional: Customize available models
OPENAI_MODEL_LIST=-all,+claude-sonnet-4-20250514,+gpt-4o,+gpt-4o-mini
```

### Option 2: UI Configuration

1. Open LobeChat Settings (gear icon)
2. Navigate to **AI Service Provider** > **OpenAI**
3. Configure:
   * **API Key**: Your TensorX API key
   * **API Proxy URL**: `https://api.tensorx.ai/v1`
4. Save settings

## Docker Deployment

Deploy LobeChat with TensorX configuration:

```yaml
# docker-compose.yml
version: '3.8'
services:
  lobe-chat:
    image: lobehub/lobe-chat
    ports:
      - "3210:3210"
    environment:
      - OPENAI_API_KEY=your-tensorx-api-key
      - OPENAI_PROXY_URL=https://api.tensorx.ai/v1
      - OPENAI_MODEL_LIST=-all,+claude-sonnet-4-20250514,+claude-3-5-sonnet-20241022,+gpt-4o,+gpt-4o-mini
```

Run with:

```bash
docker-compose up -d
```

## Vercel Deployment

When deploying to Vercel, set these environment variables in your project settings:

| Variable            | Value                                                 |
| ------------------- | ----------------------------------------------------- |
| `OPENAI_API_KEY`    | Your TensorX API key                                  |
| `OPENAI_PROXY_URL`  | `https://api.tensorx.ai/v1`                           |
| `OPENAI_MODEL_LIST` | `-all,+claude-sonnet-4-20250514,+gpt-4o,+gpt-4o-mini` |

## Model List Configuration

The `OPENAI_MODEL_LIST` environment variable controls available models:

* Use `+model-name` to add a model
* Use `-model-name` to hide a model
* Use `-all` to disable all default models first
* Use `model_name=Display Name` to customize display names

Example configurations:

```bash
# Only TensorX models
OPENAI_MODEL_LIST=-all,+claude-sonnet-4-20250514,+claude-3-5-sonnet-20241022,+gpt-4o,+gpt-4o-mini

# With custom display names
OPENAI_MODEL_LIST=-all,+claude-sonnet-4-20250514=Claude Sonnet 4,+gpt-4o=GPT-4o
```

## Available Models

See [TensorX Models](/api-reference/models) for all available models.

Popular choices for LobeChat:

| Model                        | Best For                         |
| ---------------------------- | -------------------------------- |
| `claude-sonnet-4-20250514`   | Complex conversations, analysis  |
| `claude-3-5-sonnet-20241022` | General chat, coding assistance  |
| `gpt-4o`                     | Multi-modal, image understanding |
| `gpt-4o-mini`                | Fast responses, cost-effective   |

## Troubleshooting

### Empty responses

Check that `OPENAI_PROXY_URL` includes `/v1` at the end.

### Models not appearing

Verify `OPENAI_MODEL_LIST` syntax:

* Each model should be prefixed with `+`
* Use commas without spaces to separate models

### Authentication errors

Ensure your TensorX API key is valid and has available credits.

## Resources

* [LobeChat Documentation](https://lobehub.com/docs)
* [LobeChat GitHub](https://github.com/lobehub/lobe-chat)
* [TensorX API Reference](/api-reference/overview)


# Jan

[Jan](https://jan.ai/) is a privacy-focused, open-source ChatGPT alternative that runs locally. It supports connecting to cloud providers like TensorX through OpenAI-compatible configuration.

## Prerequisites

* Jan installed from [jan.ai](https://jan.ai/)
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

### Step 1: Open Settings

1. Click the **Settings** icon (⚙️) in the bottom-left corner of Jan
2. Navigate to **Model Providers** in the left sidebar

### Step 2: Configure OpenAI Provider

1. Select **OpenAI** from the Model Providers list
2. Enter your TensorX credentials:
   * **API Key**: Your TensorX API key
   * **API Base URL**: `https://api.tensorx.ai/v1`
3. Click **Save**

### Step 3: Add TensorX Models

Jan automatically includes popular OpenAI models. To add specific TensorX models:

1. Go to **Settings** > **Model Providers** > **OpenAI**
2. Add models by their exact ID:
   * `claude-sonnet-4-20250514`
   * `claude-3-5-sonnet-20241022`
   * `gpt-4o`
   * `gpt-4o-mini`

## Using Models in Chat

1. Open a new chat or existing thread
2. Click the model selector dropdown
3. Choose your configured TensorX model
4. Start chatting!

## Manual Model Configuration

For advanced users, you can manually add models via JSON configuration:

1. Navigate to Jan Data Folder:
   * **Mac**: `~/Library/Application Support/jan/models/`
   * **Windows**: `%APPDATA%\jan\models\`
   * **Linux**: `~/.config/jan/models/`
2. Create a new folder for your model (e.g., `tensorx-claude-sonnet`)
3. Create a `model.json` file:

```json
{
  "id": "claude-sonnet-4-20250514",
  "object": "model",
  "name": "Claude Sonnet 4 (TensorX)",
  "description": "Claude Sonnet 4 via TensorX API",
  "settings": {
    "ctx_len": 200000
  },
  "parameters": {
    "temperature": 0.7,
    "top_p": 0.95,
    "stream": true,
    "max_tokens": 4096
  },
  "metadata": {
    "author": "TensorX",
    "tags": ["Claude", "Anthropic", "TensorX"]
  },
  "engine": "openai"
}
```

## Available Models

See [TensorX Models](/api-reference/models) for the complete list.

Recommended models for Jan:

| Model                        | Best For                |
| ---------------------------- | ----------------------- |
| `claude-sonnet-4-20250514`   | Complex tasks, analysis |
| `claude-3-5-sonnet-20241022` | General chat, coding    |
| `gpt-4o`                     | Multi-modal, images     |
| `gpt-4o-mini`                | Fast, cost-effective    |

## Troubleshooting

### Model not connecting

1. Verify API key is entered correctly
2. Ensure base URL is `https://api.tensorx.ai/v1` (with `/v1`)
3. Check Jan's logs for error details

### Model unavailable

* Confirm the model ID matches exactly (case-sensitive)
* Verify your TensorX account has access to the model

### Slow responses

* Check your internet connection
* Try a faster model like `gpt-4o-mini`

## Resources

* [Jan Documentation](https://jan.ai/docs)
* [Jan GitHub](https://github.com/janhq/jan)
* [TensorX API Reference](/api-reference/overview)


# SillyTavern

Connect SillyTavern to TensorX and chat with AI using a feature-rich, self-hosted frontend — powered by open-source models.

***

## Overview

[SillyTavern](https://sillytavern.app) is an open-source LLM frontend for power users, with 24K+ GitHub stars and one of the largest communities in the AI chat space. It supports OpenAI-compatible APIs, making it easy to connect to TensorX for a self-hosted, privacy-first chat experience.

{% hint style="success" %}
**Why SillyTavern + TensorX?**

* 🎭 **Rich chat experience** — Character cards, personas, world building
* 🔌 **Extensions** — TTS, image generation, web search, and more
* 📱 **Multi-device** — Access from any browser on your network
* 🔒 **Self-hosted** — Your data stays on your machine
* 💰 **Cost-effective** — Powerful open-source models at a fraction of the cost
  {% endhint %}

***

## Prerequisites

* **Node.js** 18+ ([download here](https://nodejs.org/))
* **Git**
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Installation

```bash
git clone https://github.com/SillyTavern/SillyTavern.git
cd SillyTavern
npm install
node server.js
```

Open `http://localhost:8000` in your browser.

***

## Configuration

### Step 1: Open API Settings

1. Click the **plug icon** (API Connections) in the top menu
2. Select **Chat Completion** as the API type
3. Select **Custom (OpenAI-compatible)** as the Chat Completion Source

### Step 2: Configure TensorX

| Setting                        | Value                       |
| ------------------------------ | --------------------------- |
| **Custom Endpoint (Base URL)** | `https://api.tensorx.ai/v1` |
| **API Key**                    | Your TensorX API key        |

### Step 3: Set Your Model

In the model field, type the model name directly:

| Model                       | Use Case                       |
| --------------------------- | ------------------------------ |
| `z-ai/glm-5.1` ⭐            | General use, coding, reasoning |
| `z-ai/glm-5.2`              | Balanced chat                  |
| `deepseek/deepseek-r1-0528` | Complex reasoning              |
| `minimax/minimax-m2.5`      | Function calling               |
| `moonshotai/kimi-k2.5`      | Vision, long context           |

### Step 4: Test Connection

Click **Connect** and send a test message to verify everything works.

***

## Recommended Models

| Use Case               | Model                       | Why                        |
| ---------------------- | --------------------------- | -------------------------- |
| **General chat** ⭐     | `z-ai/glm-5.1`              | Versatile, great reasoning |
| **Creative writing**   | `z-ai/glm-5.2`              | Balanced and natural       |
| **Long conversations** | `moonshotai/kimi-k2.5`      | Large context window       |
| **Deep reasoning**     | `deepseek/deepseek-r1-0528` | Complex analysis           |
| **Fast responses**     | `minimax/minimax-m2`        | Quick and cost-effective   |

***

## Optimizing Settings

### Context Size

Set the context size in SillyTavern to match your model:

* GLM-5.1: `203000`
* Kimi K2.5: `262000`
* DeepSeek: `164000`

### Response Length

Adjust **Max Response Length** based on your use case:

* Chat: `1024–2048` tokens
* Creative writing: `4096–8192` tokens
* Analysis: `8192–16384` tokens

***

## Troubleshooting

### Connection Failed

1. Verify the endpoint is exactly `https://api.tensorx.ai/v1`
2. Check your API key is correct
3. Ensure you selected **Custom (OpenAI-compatible)** not plain OpenAI

### Empty or Short Responses

Increase the **Max Response Length** in the generation settings.

### Model Not Found

Type the full model name (e.g., `z-ai/glm-5.1`) — SillyTavern may not auto-discover models from custom endpoints.

***

## See Also

* [SillyTavern Documentation](https://docs.sillytavern.app/)
* [SillyTavern on GitHub](https://github.com/SillyTavern/SillyTavern)
* [TensorX Models](https://tensorx.ai/models)


# Chatbox AI

Use TensorX models in Chatbox AI — the open-source desktop AI copilot for Mac, Windows, and Linux.

***

## Overview

[Chatbox AI](https://chatboxai.app) is an open-source desktop application that provides a clean, native interface for chatting with AI models. It supports custom OpenAI-compatible endpoints, making it easy to connect to TensorX for a private, cost-effective AI assistant on your desktop.

{% hint style="success" %}
**Why Chatbox AI + TensorX?**

* 🖥️ **Native desktop app** — Mac, Windows, and Linux
* 🔒 **Privacy-first** — Data stays on your device, no tracking
* 💬 **Multiple conversations** — Organize chats with folders and tags
* 📝 **Markdown support** — Rich text rendering with code highlighting
* 💰 **Cost-effective** — Use powerful open-source models locally
  {% endhint %}

***

## Prerequisites

* **Chatbox AI** — [Download here](https://chatboxai.app)
* A TensorX API key ([sign up here](https://app.tensorx.ai/register))

***

## Setup

### Step 1: Open Settings

1. Launch Chatbox AI
2. Click the **Settings** icon (gear) in the bottom left

### Step 2: Configure Provider

| Setting         | Value                       |
| --------------- | --------------------------- |
| **AI Provider** | `OpenAI API Compatible`     |
| **API Host**    | `https://api.tensorx.ai/v1` |
| **API Key**     | Your TensorX API key        |
| **Model**       | `z-ai/glm-5.1`              |

### Step 3: Save and Test

Click **Save** and start a new conversation to test the connection.

***

## Recommended Models

| Use Case           | Model                       | Why                             |
| ------------------ | --------------------------- | ------------------------------- |
| **General use** ⭐  | `z-ai/glm-5.1`              | Coding, reasoning, general chat |
| **Reasoning**      | `deepseek/deepseek-r1-0528` | Complex analysis                |
| **Balanced chat**  | `z-ai/glm-5.2`              | Good all-round performance      |
| **Fast responses** | `minimax/minimax-m2`        | Quick and cost-effective        |
| **Long documents** | `moonshotai/kimi-k2.5`      | Large context window            |

***

## Troubleshooting

### Connection Error

1. Verify the API Host is exactly `https://api.tensorx.ai/v1`
2. Check your API key is correct
3. Try selecting a different model

### Model Not Listed

Type the model name manually in the model field (e.g., `z-ai/glm-5.1`).

***

## See Also

* [Chatbox AI Website](https://chatboxai.app)
* [Chatbox AI on GitHub](https://github.com/Bin-Huang/chatbox)
* [TensorX Models](https://tensorx.ai/models)


# Open Notebook

Connect Open Notebook to TensorX and get a privacy-focused, self-hosted NotebookLM alternative with access to all our models.

***

## What is Open Notebook?

[Open Notebook](https://www.open-notebook.ai/) is an open-source, AI-powered note-taking and research platform. It's a privacy-first alternative to Google's NotebookLM, supporting 16+ AI providers including OpenAI-compatible APIs like TensorX.

{% hint style="success" %}
**Why Open Notebook + TensorX?**

* 🔒 **Privacy-first** - Self-hosted, your data stays under your control
* 🎙️ **Podcast generation** - Transform notes into multi-speaker audio podcasts
* 📁 **Multi-format support** - PDFs, videos, audio, web pages, and more
* 💬 **Context-aware chat** - AI conversations powered by your research
* 🔍 **Intelligent search** - Full-text and vector search across all content
  {% endhint %}

***

## Prerequisites

* Docker installed on your system
* A TensorX API key ([sign up here](https://app.tensorx.ai))
* At least 4GB RAM and 10GB disk space

***

## Quick Start with Docker

Deploy Open Notebook with TensorX in one command:

```bash
docker run -d \
  --name open-notebook \
  --restart unless-stopped \
  -p 8502:8502 \
  -e OPENAI_COMPATIBLE_BASE_URL=https://api.tensorx.ai/v1 \
  -e OPENAI_COMPATIBLE_API_KEY=your-tensorx-api-key \
  -v open-notebook-data:/data \
  ghcr.io/lfnovo/open-notebook:latest
```

{% hint style="warning" %}
**Replace** `your-tensorx-api-key` with your actual TensorX API key!
{% endhint %}

Then open `http://localhost:8502` in your browser.

***

## Docker Compose Setup

For easier management, create a `docker-compose.yml`:

```yaml
version: '3.8'

services:
  open-notebook:
    image: ghcr.io/lfnovo/open-notebook:latest
    container_name: open-notebook
    restart: unless-stopped
    ports:
      - "8502:8502"
    environment:
      - OPENAI_COMPATIBLE_BASE_URL=https://api.tensorx.ai/v1
      - OPENAI_COMPATIBLE_API_KEY=your-tensorx-api-key
    volumes:
      - open-notebook-data:/data

volumes:
  open-notebook-data:
```

Deploy with:

```bash
docker compose up -d
```

***

## Configuration

### Environment Variables

| Variable                     | Value                       | Description          |
| ---------------------------- | --------------------------- | -------------------- |
| `OPENAI_COMPATIBLE_BASE_URL` | `https://api.tensorx.ai/v1` | TensorX API endpoint |
| `OPENAI_COMPATIBLE_API_KEY`  | Your API key                | TensorX API key      |

### OpenAI-compatible Configuration

TensorX exposes a standard OpenAI-compatible API, so configure Open Notebook to point at the TensorX endpoint with your TensorX key:

```bash
OPENAI_COMPATIBLE_BASE_URL=https://api.tensorx.ai/v1
OPENAI_COMPATIBLE_API_KEY=your-tensorx-api-key
```

You can also set these in the Open Notebook settings UI: choose the **OpenAI Compatible** provider, set the **Base URL** to `https://api.tensorx.ai/v1`, and paste your TensorX API key.

***

## Setting Up Models in Open Notebook

After deployment:

1. Open `http://localhost:8502` in your browser
2. Go to **Settings** → **Models**
3. Add a new model configuration:

| Field    | Value                       |
| -------- | --------------------------- |
| Provider | OpenAI Compatible           |
| Base URL | `https://api.tensorx.ai/v1` |
| API Key  | Your TensorX API key        |
| Model    | `z-ai/glm-5.2`              |

4. Click **Save** and test the connection

***

## Recommended Models

| Use Case              | Model                               | Notes                            |
| --------------------- | ----------------------------------- | -------------------------------- |
| **General chat**      | `z-ai/glm-5.2`                      | Fast, great for everyday use     |
| **Complex reasoning** | `deepseek/deepseek-r1-0528`         | Best for analysis and research   |
| **Coding assistance** | `z-ai/glm-5.1`                      | Excellent for code-related tasks |
| **Vision tasks**      | `moonshotai/kimi-k2.5`              | Image understanding              |
| **Long documents**    | `meta-llama/llama-4-maverick`       | Long document processing         |
| **Fast responses**    | `meta-llama/llama-3.3-70b-instruct` | Quick, cost-effective            |

***

## Features with TensorX

### 📓 Notebooks

Organize your research into separate notebooks, each with its own sources and notes.

### 📄 Sources

Upload and process multiple content types:

* PDFs and documents
* YouTube videos
* Web pages
* Audio files

### 💬 Context-Aware Chat

Chat with your sources using TensorX models. The AI understands your uploaded content and provides cited answers.

### 🎙️ Podcast Generation

Transform your notes into engaging audio podcasts with multiple speakers. Configure TTS settings in Open Notebook to use TensorX's audio API.

### 🔍 Intelligent Search

Full-text and semantic search across all your content.

***

## Podcast Generation Setup

To generate podcasts with TensorX TTS:

1. Go to **Settings** → **Audio**
2. Configure TTS provider:

| Field        | Value                       |
| ------------ | --------------------------- |
| TTS Provider | OpenAI Compatible           |
| Base URL     | `https://api.tensorx.ai/v1` |
| API Key      | Your TensorX API key        |
| Model        | `chatterbox-turbo`          |

3. Create a podcast from any notebook or chat conversation

***

## Troubleshooting

### Models Not Loading

1. Verify your API key is correct
2. Check the base URL includes `/v1`: `https://api.tensorx.ai/v1`
3. Test your API key:

```bash
curl https://api.tensorx.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Connection Errors

1. Ensure Docker container is running: `docker ps`
2. Check logs: `docker logs open-notebook`
3. Verify network connectivity to `api.tensorx.ai`

### Podcast Generation Fails

1. Ensure TTS is configured correctly in Settings
2. Check that your API key has sufficient credits
3. Verify the TTS model name is correct: `chatterbox-turbo`

***

## Resources

* [Open Notebook Documentation](https://www.open-notebook.ai/)
* [Open Notebook GitHub](https://github.com/lfnovo/open-notebook)
* [TensorX Models & Pricing](https://tensorx.ai/models)
* [TensorX Audio API](/api-reference/audio)

***

## See Also

* [Audio API](/api-reference/audio) - Text-to-speech and speech-to-text
* [API Examples](/api-reference/api-examples) - Code examples for TensorX API
* [Troubleshooting](/support/troubleshooting) - Common issues and fixes


# SurfSense

Connect SurfSense to TensorX and get a powerful AI research agent with access to your internal knowledge sources and external data.

***

## What is SurfSense?

[SurfSense](https://github.com/MODSetter/SurfSense) is an open-source AI research agent and knowledge management platform. It's an alternative to NotebookLM, Perplexity, and Glean, connecting any LLM to your internal knowledge sources and external services.

{% hint style="success" %}
**Why SurfSense + TensorX?**

* 🔍 **Powerful search** - Hybrid semantic + full-text search across all your content
* 📁 **50+ file formats** - Documents, images, videos, and more
* 🔗 **External integrations** - Google Drive, Slack, Notion, GitHub, and more
* 🎙️ **Podcast generation** - Create podcasts from your research in seconds
* 👥 **Team collaboration** - Role-based access control for shared knowledge bases
  {% endhint %}

***

## Prerequisites

* Docker and Docker Compose installed
* A TensorX API key ([sign up here](https://app.tensorx.ai))
* At least 4GB RAM and 20GB disk space
* PostgreSQL with pgvector extension (included in Docker setup)

***

## Quick Start with Docker

1. Clone the SurfSense repository:

```bash
git clone https://github.com/MODSetter/SurfSense.git
cd SurfSense
```

2. Create your environment file:

```bash
cp surfsense_backend/.env.example surfsense_backend/.env
```

3. Edit `surfsense_backend/.env` and configure TensorX:

```bash
# Database (use defaults for Docker)
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense

# Authentication
AUTH_TYPE=LOCAL
SECRET_KEY=your-secure-secret-key

# Frontend URL
NEXT_FRONTEND_URL=http://localhost:3000

# Celery (Redis)
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0

# ETL Service (choose one)
ETL_SERVICE=DOCLING
```

4. Start SurfSense:

```bash
docker compose up -d
```

5. Access SurfSense at `http://localhost:3000`

***

## Configuring TensorX LLM

SurfSense uses LiteLLM for LLM integration, supporting 100+ models. Configure TensorX through the SurfSense UI:

### Step 1: Access LLM Settings

1. Log in to SurfSense at `http://localhost:3000`
2. Go to **Settings** → **LLM Configuration**

### Step 2: Add TensorX as Provider

Create a new LLM configuration:

| Field    | Value                       |
| -------- | --------------------------- |
| Provider | OpenAI Compatible           |
| Model    | `openai/z-ai/glm-5.2`       |
| API Base | `https://api.tensorx.ai/v1` |
| API Key  | Your TensorX API key        |

{% hint style="info" %}
**Model format**: Use `openai/` prefix followed by the TensorX model name. This tells LiteLLM to route requests to an OpenAI-compatible endpoint.
{% endhint %}

### Step 3: Test the Connection

Click **Test Connection** to verify your configuration works.

***

## LiteLLM Model Format

SurfSense uses LiteLLM which requires specific model naming:

```
openai/<tensorx-model-name>
```

### Examples

| TensorX Model                       | LiteLLM Format                             |
| ----------------------------------- | ------------------------------------------ |
| `z-ai/glm-5.1`                      | `openai/z-ai/glm-5.1`                      |
| `minimax/minimax-m2.5`              | `openai/minimax/minimax-m2.5`              |
| `moonshotai/kimi-k2.5`              | `openai/moonshotai/kimi-k2.5`              |
| `z-ai/glm-5.2`                      | `openai/z-ai/glm-5.2`                      |
| `deepseek/deepseek-r1-0528`         | `openai/deepseek/deepseek-r1-0528`         |
| `meta-llama/llama-3.3-70b-instruct` | `openai/meta-llama/llama-3.3-70b-instruct` |

***

## Recommended Models

| Use Case              | Model                               | LiteLLM Format                             |
| --------------------- | ----------------------------------- | ------------------------------------------ |
| **General chat**      | `z-ai/glm-5.2`                      | `openai/z-ai/glm-5.2`                      |
| **Complex reasoning** | `deepseek/deepseek-r1-0528`         | `openai/deepseek/deepseek-r1-0528`         |
| **Coding tasks**      | `z-ai/glm-5.1`                      | `openai/z-ai/glm-5.1`                      |
| **Vision tasks**      | `moonshotai/kimi-k2.5`              | `openai/moonshotai/kimi-k2.5`              |
| **Long context**      | `meta-llama/llama-4-maverick`       | `openai/meta-llama/llama-4-maverick`       |
| **Fast responses**    | `meta-llama/llama-3.3-70b-instruct` | `openai/meta-llama/llama-3.3-70b-instruct` |

***

## Configuring TTS for Podcasts

SurfSense can generate podcasts from your research. Configure TensorX TTS:

### Environment Variables

Add to your `surfsense_backend/.env`:

```bash
# Text-to-Speech
TTS_SERVICE=openai/tts-1
TTS_SERVICE_API_KEY=your-tensorx-api-key
TTS_SERVICE_API_BASE=https://api.tensorx.ai/v1
```

Or use TensorX's Chatterbox model:

```bash
TTS_SERVICE=openai/chatterbox-turbo
TTS_SERVICE_API_KEY=your-tensorx-api-key
TTS_SERVICE_API_BASE=https://api.tensorx.ai/v1
```

***

## Features with TensorX

### 🔍 Search Spaces

Create organized knowledge bases with semantic and full-text search.

### 📁 File Upload

Upload 50+ file formats including:

* Documents (PDF, Word, Excel, PowerPoint)
* Images (with OCR)
* Videos and audio files

### 🔗 External Connectors

Connect to external services:

* Google Drive, Gmail, Calendar
* Slack, Discord
* Notion, Confluence
* GitHub, Linear, Jira
* And many more

### 💬 AI Chat

Chat with your knowledge base using TensorX models. Get cited answers with source references.

### 🎙️ Podcast Generation

Generate engaging podcasts from your research:

1. Select content from your search space
2. Click **Generate Podcast**
3. Download the audio file

***

## Docker Compose Configuration

Full `docker-compose.yml` for SurfSense with TensorX:

```yaml
version: '3.8'

services:
  postgres:
    image: pgvector/pgvector:pg16
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: surfsense
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  redis:
    image: redis:alpine
    ports:
      - "6379:6379"

  backend:
    build: ./surfsense_backend
    environment:
      - DATABASE_URL=postgresql+asyncpg://postgres:postgres@postgres:5432/surfsense
      - SECRET_KEY=your-secure-secret-key
      - AUTH_TYPE=LOCAL
      - NEXT_FRONTEND_URL=http://localhost:3000
      - CELERY_BROKER_URL=redis://redis:6379/0
      - CELERY_RESULT_BACKEND=redis://redis:6379/0
      - ETL_SERVICE=DOCLING
      - TTS_SERVICE=openai/chatterbox-turbo
      - TTS_SERVICE_API_KEY=your-tensorx-api-key
      - TTS_SERVICE_API_BASE=https://api.tensorx.ai/v1
    ports:
      - "8000:8000"
    depends_on:
      - postgres
      - redis

  frontend:
    build: ./surfsense_web
    environment:
      - NEXT_PUBLIC_FASTAPI_BACKEND_URL=http://localhost:8000
      - NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE=LOCAL
      - NEXT_PUBLIC_ETL_SERVICE=DOCLING
    ports:
      - "3000:3000"
    depends_on:
      - backend

volumes:
  postgres_data:
```

***

## Troubleshooting

### LLM Not Responding

1. Verify the model format includes `openai/` prefix
2. Check API base URL: `https://api.tensorx.ai/v1`
3. Test your API key:

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
```

### Podcast Generation Fails

1. Verify TTS environment variables are set correctly
2. Check that `TTS_SERVICE_API_BASE` includes `/v1`
3. Ensure your API key has sufficient credits

### Database Connection Issues

1. Ensure PostgreSQL is running: `docker ps`
2. Check pgvector extension is installed
3. Verify `DATABASE_URL` format

### Check Logs

```bash
# Backend logs
docker logs surfsense-backend-1

# All services
docker compose logs -f
```

***

## Resources

* [SurfSense Documentation](https://www.surfsense.com/docs/)
* [SurfSense GitHub](https://github.com/MODSetter/SurfSense)
* [LiteLLM Providers](https://docs.litellm.ai/docs/providers)
* [TensorX Models & Pricing](https://tensorx.ai/models)

***

## See Also

* [Audio API](/api-reference/audio) - Text-to-speech and speech-to-text
* [API Examples](/api-reference/api-examples) - Code examples for TensorX API
* [Open Notebook](/research-and-knowledge/open-notebook) - Another NotebookLM alternative


# Podcastfy

Transform any content into engaging AI-generated podcasts using TensorX models.

***

## What is Podcastfy?

[Podcastfy](https://github.com/souzatharsis/podcastfy) is an open-source Python package that transforms multi-modal content (text, images, websites, PDFs, YouTube videos) into engaging, multi-lingual audio conversations. It's an open-source alternative to NotebookLM's podcast feature.

{% hint style="success" %}
**Why Podcastfy + TensorX?**

* 🎧 **Multi-modal input** - Websites, PDFs, images, YouTube videos, and more
* 🌍 **Multilingual** - Generate podcasts in multiple languages
* ⚡ **Fast generation** - Create 3-minute podcasts in under 20 seconds
* 🎨 **Customizable** - Control conversation style, length, and voices
* 📦 **Python & CLI** - Use as a library or command-line tool
  {% endhint %}

***

## Prerequisites

* Python 3.11 or higher
* ffmpeg installed (`pip install ffmpeg` or system package)
* A TensorX API key ([sign up here](https://app.tensorx.ai))

***

## Installation

```bash
pip install podcastfy
```

***

## Quick Start

### Python

```python
from podcastfy.client import generate_podcast

# Generate podcast from URLs using TensorX
audio_file = generate_podcast(
    urls=["https://en.wikipedia.org/wiki/Artificial_intelligence"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)

print(f"Podcast saved to: {audio_file}")
```

### CLI

```bash
python -m podcastfy.client \
  --url https://en.wikipedia.org/wiki/Artificial_intelligence \
  --llm-model-name openai/z-ai/glm-5.2
```

***

## Configuration

### Environment Variables

Create a `.env` file in your project root:

```bash
# TensorX API Key (used for both LLM and TTS)
OPENAI_API_KEY=your-tensorx-api-key

# TensorX API Base URL
OPENAI_BASE_URL=https://api.tensorx.ai/v1
```

{% hint style="warning" %}
**Note**: The environment variable is `OPENAI_BASE_URL` (not `OPENAI_API_BASE`). This is the standard LiteLLM format.
{% endhint %}

### Using TensorX for Transcript Generation

Podcastfy uses LiteLLM for LLM support. To use TensorX models:

```python
from podcastfy.client import generate_podcast

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

{% hint style="info" %}
**Model format**: Use `openai/` prefix followed by the TensorX model name. This tells LiteLLM to route requests to an OpenAI-compatible endpoint.
{% endhint %}

***

## LiteLLM Model Format

Podcastfy uses LiteLLM which requires specific model naming for OpenAI-compatible APIs:

```
openai/<tensorx-model-name>
```

### Examples

| TensorX Model                       | LiteLLM Format                             |
| ----------------------------------- | ------------------------------------------ |
| `z-ai/glm-5.1`                      | `openai/z-ai/glm-5.1`                      |
| `minimax/minimax-m2.5`              | `openai/minimax/minimax-m2.5`              |
| `moonshotai/kimi-k2.5`              | `openai/moonshotai/kimi-k2.5`              |
| `z-ai/glm-5.2`                      | `openai/z-ai/glm-5.2`                      |
| `deepseek/deepseek-r1-0528`         | `openai/deepseek/deepseek-r1-0528`         |
| `meta-llama/llama-3.3-70b-instruct` | `openai/meta-llama/llama-3.3-70b-instruct` |

***

## Recommended Models

| Use Case              | Model                         | Notes                                   |
| --------------------- | ----------------------------- | --------------------------------------- |
| **General podcasts**  | `z-ai/glm-5.2`                | Fast, great conversational quality      |
| **In-depth analysis** | `deepseek/deepseek-r1-0528`   | Better reasoning for complex topics     |
| **Technical content** | `z-ai/glm-5.1`                | Good for code and technical discussions |
| **Vision content**    | `moonshotai/kimi-k2.5`        | Image understanding                     |
| **Long content**      | `meta-llama/llama-4-maverick` | Long document processing                |

***

## Text-to-Speech with TensorX

Configure TensorX TTS for audio generation:

```python
from podcastfy.client import generate_podcast

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    tts_model="openai"  # Uses OpenAI-compatible TTS
)
```

### Environment Variables for TTS

```bash
# In your .env file
OPENAI_API_KEY=your-tensorx-api-key
OPENAI_BASE_URL=https://api.tensorx.ai/v1
```

***

## Customization

### Conversation Style

Customize the podcast conversation:

```python
from podcastfy.client import generate_podcast

custom_config = {
    "word_count": 500,
    "conversation_style": ["casual", "informative"],
    "podcast_name": "Tech Insights",
    "creativity": 0.7,
    "output_language": "English"
}

audio_file = generate_podcast(
    urls=["https://example.com/tech-news"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    conversation_config=custom_config
)
```

### CLI with Custom Config

Create a `custom_config.yaml`:

```yaml
word_count: 500
conversation_style:
  - casual
  - informative
podcast_name: "Tech Insights"
creativity: 0.7
output_language: English
```

Run with:

```bash
python -m podcastfy.client \
  --url https://example.com/article \
  --llm-model-name openai/z-ai/glm-5.2 \
  --conversation-config custom_config.yaml
```

***

## Generate from Multiple Sources

### Multiple URLs

```python
audio_file = generate_podcast(
    urls=[
        "https://example.com/article1",
        "https://example.com/article2",
        "https://youtube.com/watch?v=example"
    ],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

### From PDF Files

```python
audio_file = generate_podcast(
    urls=["path/to/document.pdf"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

### From Images

```python
audio_file = generate_podcast(
    urls=["path/to/image1.jpg", "path/to/image2.png"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

***

## Longform Podcasts

Generate longer podcasts (20-30 minutes):

```python
audio_file = generate_podcast(
    urls=["https://example.com/long-article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    longform=True
)
```

### Customize Longform Length

```python
custom_config = {
    "max_num_chunks": 10,  # More chunks = longer podcast
    "min_chunk_size": 400  # Smaller chunks = more detail
}

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    longform=True,
    conversation_config=custom_config
)
```

***

## Transcript Only

Generate just the transcript without audio:

```python
from podcastfy.client import generate_podcast

transcript = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    transcript_only=True
)

print(transcript)
```

### CLI

```bash
python -m podcastfy.client \
  --url https://example.com/article \
  --llm-model-name openai/z-ai/glm-5.2 \
  --transcript-only
```

***

## Multilingual Podcasts

Generate podcasts in different languages:

```python
custom_config = {
    "output_language": "French"
}

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    conversation_config=custom_config
)
```

Supported languages depend on the TTS model capabilities.

***

## Troubleshooting

### API Key Errors

1. Verify your `.env` file contains:

   ```bash
   OPENAI_API_KEY=your-tensorx-api-key
   OPENAI_API_BASE=https://api.tensorx.ai/v1
   ```
2. Test your API key:

   ```bash
   curl https://api.tensorx.ai/v1/models \
     -H "Authorization: Bearer YOUR_API_KEY"
   ```

### Model Not Found

Ensure you're using the correct LiteLLM format:

* ✅ `openai/z-ai/glm-5.2`
* ❌ `z-ai/glm-5.2`

### Audio Generation Fails

1. Ensure ffmpeg is installed: `ffmpeg -version`
2. Check TTS configuration in your environment
3. Verify API key has sufficient credits

### Content Extraction Fails

1. Check the URL is accessible
2. For PDFs, ensure the file path is correct
3. For YouTube, verify the video is public

***

## Complete Example

```python
import os
from podcastfy.client import generate_podcast

# Set environment variables
os.environ["OPENAI_API_KEY"] = "your-tensorx-api-key"
os.environ["OPENAI_BASE_URL"] = "https://api.tensorx.ai/v1"

# Custom configuration
config = {
    "word_count": 800,
    "conversation_style": ["engaging", "educational"],
    "podcast_name": "AI Weekly",
    "creativity": 0.8
}

# Generate podcast
audio_file = generate_podcast(
    urls=[
        "https://en.wikipedia.org/wiki/Large_language_model",
        "https://en.wikipedia.org/wiki/Transformer_(deep_learning_architecture)"
    ],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    conversation_config=config
)

print(f"🎙️ Podcast generated: {audio_file}")
```

***

## Resources

* [Podcastfy Documentation](https://podcastfy.readthedocs.io/)
* [Podcastfy GitHub](https://github.com/souzatharsis/podcastfy)
* [LiteLLM Providers](https://docs.litellm.ai/docs/providers)
* [TensorX Models & Pricing](https://tensorx.ai/models)

***

## See Also

* [Audio API](/api-reference/audio) - TensorX text-to-speech and speech-to-text
* [API Examples](/api-reference/api-examples) - Code examples for TensorX API
* [SurfSense](/research-and-knowledge/surfsense) - Another tool with podcast generation
* [Open Notebook](/research-and-knowledge/open-notebook) - NotebookLM alternative with podcasts


# AnythingLLM

Connect AnythingLLM to TensorX and chat with your documents using any of our models.

***

## What is AnythingLLM?

[AnythingLLM](https://anythingllm.com/) is an all-in-one AI application that lets you chat with your documents, use AI agents, and manage multiple workspaces. It supports many LLM providers including OpenAI-compatible APIs like TensorX.

{% hint style="success" %}
**Why AnythingLLM + TensorX?**

* 📁 **Document chat** - Upload PDFs, docs, and more to chat with your content
* 🤖 **AI Agents** - Build custom agents that can browse the web and use tools
* 👥 **Multi-user** - Support for teams with permissions (Docker version)
* 🔌 **Embeddable** - Create chat widgets for your website
* 🖥️ **Desktop & Docker** - Run locally or self-host
  {% endhint %}

***

## Prerequisites

* AnythingLLM installed ([Desktop](https://anythingllm.com/download) or [Docker](https://github.com/Mintplex-Labs/anything-llm/blob/master/docker/HOW_TO_USE_DOCKER.md))
* A TensorX API key ([sign up here](https://app.tensorx.ai))

***

## Configuration

AnythingLLM supports TensorX through the **OpenAI (Generic)** provider.

### Step 1: Open LLM Settings

1. Launch AnythingLLM
2. Click the **Settings** gear icon
3. Navigate to **LLM** settings

### Step 2: Select OpenAI (Generic)

1. In the LLM provider dropdown, select **OpenAI (Generic)**
2. Configure the following settings:

| Field      | Value                            |
| ---------- | -------------------------------- |
| Base URL   | `https://api.tensorx.ai/v1`      |
| API Key    | Your TensorX API key             |
| Model Name | `z-ai/glm-5.2`                   |
| Max Tokens | `4096` (or your preferred limit) |

3. Click **Save Changes**

{% hint style="warning" %}
**Important**: The Base URL must include `/v1` at the end.
{% endhint %}

***

## Docker Deployment

Deploy AnythingLLM with TensorX pre-configured:

```bash
docker run -d \
  --name anythingllm \
  -p 3001:3001 \
  -v anythingllm-data:/app/server/storage \
  -e LLM_PROVIDER=generic-openai \
  -e GENERIC_OPEN_AI_BASE_PATH=https://api.tensorx.ai/v1 \
  -e GENERIC_OPEN_AI_API_KEY=your-tensorx-api-key \
  -e GENERIC_OPEN_AI_MODEL_PREF=z-ai/glm-5.2 \
  mintplexlabs/anythingllm
```

Then open `http://localhost:3001` in your browser.

### Docker Compose

```yaml
version: '3.8'

services:
  anythingllm:
    image: mintplexlabs/anythingllm
    container_name: anythingllm
    ports:
      - "3001:3001"
    environment:
      - LLM_PROVIDER=generic-openai
      - GENERIC_OPEN_AI_BASE_PATH=https://api.tensorx.ai/v1
      - GENERIC_OPEN_AI_API_KEY=your-tensorx-api-key
      - GENERIC_OPEN_AI_MODEL_PREF=z-ai/glm-5.2
      - GENERIC_OPEN_AI_MAX_TOKENS=4096
    volumes:
      - anythingllm-data:/app/server/storage

volumes:
  anythingllm-data:
```

Deploy with:

```bash
docker compose up -d
```

***

## Recommended Models

| Use Case              | Model                               | Notes                            |
| --------------------- | ----------------------------------- | -------------------------------- |
| **General chat**      | `z-ai/glm-5.2`                      | Fast, great for everyday use     |
| **Complex reasoning** | `deepseek/deepseek-r1-0528`         | Best for analysis and research   |
| **Coding assistance** | `z-ai/glm-5.1`                      | Excellent for code-related tasks |
| **Vision tasks**      | `moonshotai/kimi-k2.5`              | Image understanding              |
| **Long documents**    | `meta-llama/llama-4-maverick`       | Long document processing         |
| **Fast responses**    | `meta-llama/llama-3.3-70b-instruct` | Quick, cost-effective            |

***

## Workspace Configuration

You can set different models per workspace:

1. Open a workspace
2. Click the **Settings** icon for that workspace
3. Under **Chat Settings**, select **Workspace LLM**
4. Choose **OpenAI (Generic)** and configure with a different TensorX model

This allows you to use different models for different use cases within the same AnythingLLM instance.

***

## Features with TensorX

### 📁 Document Upload

Upload and chat with various document types:

* PDFs
* Word documents (.docx)
* Text files
* Web pages (via URL)
* And more

### 🤖 AI Agents

Create custom agents that can:

* Browse the web
* Execute code
* Use custom tools
* Access your documents

### 💬 Workspaces

Organize your documents into separate workspaces, each with its own:

* Document collection
* Chat history
* Model settings

### 🔌 Embed Widget

Create embeddable chat widgets for your website (Docker version only).

***

## Environment Variables

For Docker deployments, these environment variables configure TensorX:

| Variable                     | Value                       | Description                    |
| ---------------------------- | --------------------------- | ------------------------------ |
| `LLM_PROVIDER`               | `generic-openai`            | Use OpenAI-compatible provider |
| `GENERIC_OPEN_AI_BASE_PATH`  | `https://api.tensorx.ai/v1` | TensorX API endpoint           |
| `GENERIC_OPEN_AI_API_KEY`    | Your API key                | TensorX API key                |
| `GENERIC_OPEN_AI_MODEL_PREF` | Model name                  | Default model to use           |
| `GENERIC_OPEN_AI_MAX_TOKENS` | `4096`                      | Max tokens per response        |

***

## Troubleshooting

### "Invalid API Key" Error

1. Verify your API key is correct
2. Check that the key has available credits
3. Test your key:

```bash
curl https://api.tensorx.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### "Model Not Found" Error

1. Verify the model name is correct (e.g., `z-ai/glm-5.2`)
2. Check available models at [tensorx.ai/models](https://tensorx.ai/models)

### Connection Errors

1. Ensure Base URL is `https://api.tensorx.ai/v1` (with `/v1`)
2. Check your internet connection
3. Verify no firewall is blocking the connection

### Slow Responses

1. Try a faster model like `meta-llama/llama-3.3-70b-instruct`
2. Reduce the document size in your workspace
3. Lower the max tokens setting

### Check Logs (Docker)

```bash
docker logs anythingllm
```

***

## Resources

* [AnythingLLM Documentation](https://docs.anythingllm.com/)
* [AnythingLLM GitHub](https://github.com/Mintplex-Labs/anything-llm)
* [TensorX Models & Pricing](https://tensorx.ai/models)

***

## See Also

* [Open WebUI](/chat-interfaces/openwebui) - Another self-hosted chat interface
* [LibreChat](/chat-interfaces/librechat) - Multi-provider chat interface
* [API Examples](/api-reference/api-examples) - Code examples for TensorX API


# LangChain

Use TensorX models with [LangChain](https://python.langchain.com/), the popular framework for building LLM-powered applications.

## Installation

```bash
pip install -U langchain-openai
```

## Quick Start

```python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="z-ai/glm-5.1",
    base_url="https://api.tensorx.ai/v1",
    api_key="your-tensorx-api-key",
)

response = llm.invoke("Hello, how are you?")
print(response.content)
```

## Configuration

LangChain's `ChatOpenAI` class supports OpenAI-compatible APIs through the `base_url` parameter.

| Parameter  | Value                       |
| ---------- | --------------------------- |
| `base_url` | `https://api.tensorx.ai/v1` |
| `api_key`  | Your TensorX API key        |
| `model`    | Any TensorX model ID        |

## Examples

### Basic Chat

```python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="z-ai/glm-5.1",
    base_url="https://api.tensorx.ai/v1",
    api_key="your-tensorx-api-key",
    temperature=0.7,
)

messages = [
    ("system", "You are a helpful assistant."),
    ("human", "What is the capital of France?"),
]

response = llm.invoke(messages)
print(response.content)
```

### Streaming

```python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="minimax/minimax-m2",
    base_url="https://api.tensorx.ai/v1",
    api_key="your-tensorx-api-key",
)

for chunk in llm.stream("Tell me a short story"):
    print(chunk.content, end="", flush=True)
```

### Tool Calling

```python
from langchain_openai import ChatOpenAI
from pydantic import BaseModel, Field

class GetWeather(BaseModel):
    """Get current weather for a location"""
    location: str = Field(description="City and state, e.g. San Francisco, CA")

llm = ChatOpenAI(
    model="z-ai/glm-5.1",
    base_url="https://api.tensorx.ai/v1",
    api_key="your-tensorx-api-key",
)

llm_with_tools = llm.bind_tools([GetWeather])
response = llm_with_tools.invoke("What's the weather in Tokyo?")
print(response.tool_calls)
```

### Structured Output

```python
from langchain_openai import ChatOpenAI
from pydantic import BaseModel

class Joke(BaseModel):
    setup: str
    punchline: str

llm = ChatOpenAI(
    model="minimax/minimax-m2",
    base_url="https://api.tensorx.ai/v1",
    api_key="your-tensorx-api-key",
)

structured_llm = llm.with_structured_output(Joke)
result = structured_llm.invoke("Tell me a programming joke")
print(f"Setup: {result.setup}")
print(f"Punchline: {result.punchline}")
```

### Async Usage

```python
import asyncio
from langchain_openai import ChatOpenAI

async def main():
    llm = ChatOpenAI(
        model="z-ai/glm-5.1",
        base_url="https://api.tensorx.ai/v1",
        api_key="your-tensorx-api-key",
    )
    
    response = await llm.ainvoke("Hello!")
    print(response.content)

asyncio.run(main())
```

## Available Models

| Model        | ID                     | Best For                        |
| ------------ | ---------------------- | ------------------------------- |
| GLM-5.1 ⭐    | `z-ai/glm-5.1`         | Coding, reasoning, functions    |
| MiniMax-M2.5 | `minimax/minimax-m2.5` | Reasoning, functions            |
| Kimi-K2.5    | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| MiniMax-M2   | `minimax/minimax-m2`   | Coding, fast responses          |

## Tips

* Use `z-ai/glm-5.1` for applications that require tool/function calling
* Use `minimax/minimax-m2` for reasoning tasks and long conversations
* Set `temperature=0` for deterministic outputs

## Resources

* [LangChain ChatOpenAI Docs](https://python.langchain.com/docs/integrations/chat/openai/)
* [TensorX API Reference](/api-reference/overview)


# LlamaIndex

[LlamaIndex](https://www.llamaindex.ai/) is a data framework for LLM applications. Connect it to TensorX using the OpenAI-compatible configuration.

## Prerequisites

* Python 3.8+
* LlamaIndex installed
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Installation

```bash
pip install llama-index llama-index-llms-openai
```

## Configuration

### Basic Usage

```python
import os
from llama_index.llms.openai import OpenAI

# Set environment variables
os.environ["OPENAI_API_KEY"] = "your-tensorx-api-key"
os.environ["OPENAI_API_BASE"] = "https://api.tensorx.ai/v1"

# Create LLM instance
llm = OpenAI(
    model="claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1"
)

# Simple completion
response = llm.complete("Explain quantum computing in simple terms")
print(response)
```

### Chat Interface

```python
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai import OpenAI

llm = OpenAI(
    model="claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1"
)

messages = [
    ChatMessage(role="system", content="You are a helpful coding assistant"),
    ChatMessage(role="user", content="Write a Python function to calculate fibonacci numbers")
]

response = llm.chat(messages)
print(response)
```

### Streaming Responses

```python
from llama_index.llms.openai import OpenAI

llm = OpenAI(
    model="gpt-4o",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1"
)

# Streaming completion
response = llm.stream_complete("Write a short story about AI")
for chunk in response:
    print(chunk.delta, end="")
```

## RAG Applications

Build retrieval-augmented generation (RAG) systems with TensorX:

```python
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.llms.openai import OpenAI
from llama_index.embeddings.openai import OpenAIEmbedding

# Configure TensorX LLM
Settings.llm = OpenAI(
    model="claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1"
)

# Configure embeddings (if using TensorX embeddings)
Settings.embed_model = OpenAIEmbedding(
    model="text-embedding-3-small",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1"
)

# Load documents
documents = SimpleDirectoryReader("./data").load_data()

# Create index
index = VectorStoreIndex.from_documents(documents)

# Query
query_engine = index.as_query_engine()
response = query_engine.query("What are the key points in these documents?")
print(response)
```

## Agent Applications

Create agents with TensorX:

```python
from llama_index.core.agent import ReActAgent
from llama_index.core.tools import FunctionTool
from llama_index.llms.openai import OpenAI

# Define tools
def multiply(a: int, b: int) -> int:
    """Multiply two numbers."""
    return a * b

def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

multiply_tool = FunctionTool.from_defaults(fn=multiply)
add_tool = FunctionTool.from_defaults(fn=add)

# Create agent
llm = OpenAI(
    model="gpt-4o",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1"
)

agent = ReActAgent.from_tools(
    [multiply_tool, add_tool],
    llm=llm,
    verbose=True
)

response = agent.chat("What is 20 plus 30, then multiplied by 2?")
print(response)
```

## Configuration with Settings

For global configuration across your application:

```python
from llama_index.core import Settings
from llama_index.llms.openai import OpenAI

# Set global LLM
Settings.llm = OpenAI(
    model="claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1",
    temperature=0.7,
    max_tokens=4000
)
```

## Available Models

See [TensorX Models](/api-reference/models) for all available models.

| Model                        | Best For                 |
| ---------------------------- | ------------------------ |
| `claude-sonnet-4-20250514`   | Complex RAG, agents      |
| `claude-3-5-sonnet-20241022` | General LLM tasks        |
| `gpt-4o`                     | Multi-modal applications |
| `gpt-4o-mini`                | Cost-effective inference |

## Troubleshooting

### Connection errors

Ensure `api_base` ends with `/v1`:

```python
api_base="https://api.tensorx.ai/v1"  # Correct
api_base="https://api.tensorx.ai"     # Wrong
```

### Token limits

Adjust `max_tokens` based on your needs:

```python
llm = OpenAI(
    model="claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    api_base="https://api.tensorx.ai/v1",
    max_tokens=8000  # Increase if needed
)
```

## Resources

* [LlamaIndex Documentation](https://docs.llamaindex.ai/)
* [LlamaIndex GitHub](https://github.com/run-llama/llama_index)
* [TensorX API Reference](/api-reference/overview)


# Vercel AI SDK

The [Vercel AI SDK](https://sdk.vercel.ai/) is a TypeScript toolkit for building AI-powered applications. Connect it to TensorX using the OpenAI-compatible provider.

## Prerequisites

* Node.js 18+
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Installation

```bash
npm install ai @ai-sdk/openai-compatible
# or
pnpm add ai @ai-sdk/openai-compatible
# or
yarn add ai @ai-sdk/openai-compatible
```

## Configuration

### Create Provider Instance

```typescript
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,
  baseURL: 'https://api.tensorx.ai/v1',
});
```

### Environment Variables

Create a `.env.local` file:

```env
TENSORX_API_KEY=your-tensorx-api-key
```

## Usage Examples

### Text Generation

```typescript
import { generateText } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,
  baseURL: 'https://api.tensorx.ai/v1',
});

const { text } = await generateText({
  model: tensorx('claude-sonnet-4-20250514'),
  prompt: 'Write a haiku about programming.',
});

console.log(text);
```

### Streaming Text

```typescript
import { streamText } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,
  baseURL: 'https://api.tensorx.ai/v1',
});

const { textStream } = await streamText({
  model: tensorx('gpt-4o'),
  prompt: 'Explain the theory of relativity.',
});

for await (const chunk of textStream) {
  process.stdout.write(chunk);
}
```

### Chat Completions

```typescript
import { generateText } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,
  baseURL: 'https://api.tensorx.ai/v1',
});

const { text } = await generateText({
  model: tensorx('claude-sonnet-4-20250514'),
  messages: [
    { role: 'system', content: 'You are a helpful coding assistant.' },
    { role: 'user', content: 'How do I create a REST API in Node.js?' },
  ],
});

console.log(text);
```

### Structured Output

```typescript
import { generateObject } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { z } from 'zod';

const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,
  baseURL: 'https://api.tensorx.ai/v1',
});

const { object } = await generateObject({
  model: tensorx('gpt-4o'),
  schema: z.object({
    recipe: z.object({
      name: z.string(),
      ingredients: z.array(z.string()),
      steps: z.array(z.string()),
    }),
  }),
  prompt: 'Generate a recipe for chocolate chip cookies.',
});

console.log(object.recipe);
```

## Next.js Integration

### API Route (App Router)

```typescript
// app/api/chat/route.ts
import { streamText } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,
  baseURL: 'https://api.tensorx.ai/v1',
});

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = await streamText({
    model: tensorx('claude-sonnet-4-20250514'),
    messages,
  });

  return result.toDataStreamResponse();
}
```

### React Component

```typescript
// components/Chat.tsx
'use client';

import { useChat } from 'ai/react';

export default function Chat() {
  const { messages, input, handleInputChange, handleSubmit } = useChat({
    api: '/api/chat',
  });

  return (
    <div>
      {messages.map((m) => (
        <div key={m.id}>
          <strong>{m.role}:</strong> {m.content}
        </div>
      ))}
      
      <form onSubmit={handleSubmit}>
        <input
          value={input}
          onChange={handleInputChange}
          placeholder="Say something..."
        />
        <button type="submit">Send</button>
      </form>
    </div>
  );
}
```

## Tool Calling

```typescript
import { generateText, tool } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { z } from 'zod';

const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,
  baseURL: 'https://api.tensorx.ai/v1',
});

const result = await generateText({
  model: tensorx('gpt-4o'),
  tools: {
    weather: tool({
      description: 'Get the weather in a location',
      parameters: z.object({
        location: z.string().describe('The location to get weather for'),
      }),
      execute: async ({ location }) => {
        // Implement weather lookup
        return { temperature: 72, condition: 'sunny' };
      },
    }),
  },
  prompt: 'What is the weather in San Francisco?',
});

console.log(result);
```

## Available Models

See [TensorX Models](/api-reference/models) for all available models.

| Model                        | Best For                       |
| ---------------------------- | ------------------------------ |
| `claude-sonnet-4-20250514`   | Complex reasoning, coding      |
| `claude-3-5-sonnet-20241022` | General chat, analysis         |
| `gpt-4o`                     | Multi-modal, tool calling      |
| `gpt-4o-mini`                | Fast responses, cost-effective |

## Troubleshooting

### API connection errors

Verify your configuration:

```typescript
const tensorx = createOpenAICompatible({
  name: 'tensorx',
  apiKey: process.env.TENSORX_API_KEY,  // Must be set
  baseURL: 'https://api.tensorx.ai/v1',  // Include /v1
});
```

### Streaming not working

Ensure you're using `streamText` instead of `generateText` and returning `toDataStreamResponse()`.

## Resources

* [Vercel AI SDK Documentation](https://sdk.vercel.ai/)
* [Vercel AI SDK GitHub](https://github.com/vercel/ai)
* [TensorX API Reference](/api-reference/overview)


# CrewAI

[CrewAI](https://www.crewai.com/) is a framework for orchestrating role-playing AI agents. Connect it to TensorX using the OpenAI-compatible configuration.

## Prerequisites

* Python 3.10+
* CrewAI installed
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Installation

```bash
pip install crewai
# or with OpenAI support
pip install "crewai[openai]"
```

## Configuration

### Environment Variables

Set environment variables in your `.env` file:

```env
OPENAI_API_KEY=your-tensorx-api-key
OPENAI_BASE_URL=https://api.tensorx.ai/v1
MODEL=openai/claude-sonnet-4-20250514
```

### Direct Code Configuration

```python
from crewai import LLM

llm = LLM(
    model="openai/claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1",
    temperature=0.7,
    max_tokens=4000
)
```

## Basic Usage

### Creating Agents

```python
from crewai import Agent, LLM

# Configure TensorX LLM
llm = LLM(
    model="openai/claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

# Create an agent
researcher = Agent(
    role="Research Analyst",
    goal="Find and summarize the latest AI trends",
    backstory="You are an expert research analyst specializing in AI technology",
    llm=llm,
    verbose=True
)
```

### Creating Tasks

```python
from crewai import Task

research_task = Task(
    description="Research the latest developments in large language models and summarize key findings",
    expected_output="A comprehensive summary of LLM developments in 2024",
    agent=researcher
)
```

### Running a Crew

```python
from crewai import Crew, Agent, Task, LLM

# Configure LLM
llm = LLM(
    model="openai/claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

# Create agents
researcher = Agent(
    role="Research Analyst",
    goal="Research and analyze information",
    backstory="Expert analyst with deep research skills",
    llm=llm
)

writer = Agent(
    role="Content Writer",
    goal="Write clear and engaging content",
    backstory="Professional writer with technical expertise",
    llm=llm
)

# Create tasks
research_task = Task(
    description="Research the benefits of AI in healthcare",
    expected_output="Key findings about AI healthcare applications",
    agent=researcher
)

writing_task = Task(
    description="Write a blog post based on the research findings",
    expected_output="A 500-word blog post about AI in healthcare",
    agent=writer
)

# Create and run crew
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    verbose=True
)

result = crew.kickoff()
print(result)
```

## YAML Configuration

For larger projects, use YAML configuration:

### agents.yaml

```yaml
researcher:
  role: Research Analyst
  goal: Conduct comprehensive research and analysis
  backstory: A dedicated research professional with years of experience
  verbose: true
  llm: openai/claude-sonnet-4-20250514

writer:
  role: Content Writer
  goal: Create engaging and informative content
  backstory: Expert writer with technical communication skills
  verbose: true
  llm: openai/gpt-4o
```

### tasks.yaml

```yaml
research_task:
  description: Research the specified topic thoroughly
  expected_output: Detailed research findings with citations
  agent: researcher

writing_task:
  description: Write content based on research findings
  expected_output: Well-structured article or report
  agent: writer
```

## Advanced Configuration

### Custom Parameters

```python
from crewai import LLM

llm = LLM(
    model="openai/claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1",
    temperature=0.7,
    max_tokens=4000,
    top_p=0.9,
    frequency_penalty=0.1,
    presence_penalty=0.1,
    timeout=120,
    max_retries=3,
    stream=True
)
```

### Multiple Models per Crew

```python
from crewai import Agent, LLM

# High-capability model for complex tasks
claude_llm = LLM(
    model="openai/claude-sonnet-4-20250514",
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

# Fast model for simple tasks
gpt_mini_llm = LLM(
    model="openai/gpt-4o-mini",
    api_key="your-tensorx-api-key",
    base_url="https://api.tensorx.ai/v1"
)

# Complex reasoning agent
analyst = Agent(
    role="Senior Analyst",
    goal="Perform deep analysis",
    backstory="Expert analyst",
    llm=claude_llm
)

# Quick response agent
assistant = Agent(
    role="Assistant",
    goal="Handle routine tasks",
    backstory="Efficient assistant",
    llm=gpt_mini_llm
)
```

## Available Models

See [TensorX Models](/api-reference/models) for all available models.

| Model                               | Best For                  |
| ----------------------------------- | ------------------------- |
| `openai/claude-sonnet-4-20250514`   | Complex reasoning, agents |
| `openai/claude-3-5-sonnet-20241022` | General tasks             |
| `openai/gpt-4o`                     | Multi-modal, tool use     |
| `openai/gpt-4o-mini`                | Fast, cost-effective      |

**Note:** Prefix model names with `openai/` when using with CrewAI.

## Troubleshooting

### Connection errors

Ensure environment variables are set:

```bash
export OPENAI_API_KEY=your-tensorx-api-key
export OPENAI_BASE_URL=https://api.tensorx.ai/v1
```

### Model not found

Use the `openai/` prefix for model names:

```python
llm = LLM(model="openai/claude-sonnet-4-20250514")  # Correct
llm = LLM(model="claude-sonnet-4-20250514")         # May not work
```

### Timeout issues

Increase timeout for complex tasks:

```python
llm = LLM(
    model="openai/claude-sonnet-4-20250514",
    timeout=300  # 5 minutes
)
```

## Resources

* [CrewAI Documentation](https://docs.crewai.com/)
* [CrewAI GitHub](https://github.com/crewAIInc/crewAI)
* [TensorX API Reference](/api-reference/overview)


# n8n

Build powerful AI workflows with TensorX and n8n, the open-source automation platform.

***

## Overview

[n8n](https://n8n.io/) is a popular workflow automation tool that supports custom AI integrations. With TensorX's OpenAI-compatible API, you can use any of our models in your n8n workflows.

### What You Can Build

* 🤖 **AI Agents** - Autonomous agents with tool calling
* 📧 **Email Assistants** - Auto-respond, classify, summarize emails
* 📊 **Data Processing** - Analyze and transform data with AI
* 💬 **Chatbots** - Deploy conversational AI on any channel
* 📝 **Content Pipelines** - Generate, edit, translate content
* 🔍 **RAG Systems** - Build knowledge-based Q\&A workflows

***

## Prerequisites

* n8n instance (Cloud or self-hosted)
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

***

## Method 1: OpenAI Chat Model Node (Recommended)

The easiest way to use TensorX with n8n's AI features like AI Agents and LangChain nodes.

### Step 1: Create OpenAI Credentials

1. In n8n, go to **Credentials** → **Add Credential**
2. Search for **OpenAI API**
3. Configure the credential:

| Field               | Value                       |
| ------------------- | --------------------------- |
| **API Key**         | Your TensorX API key        |
| **Base URL**        | `https://api.tensorx.ai/v1` |
| **Organization ID** | Leave empty                 |

4. Click **Save**

### Step 2: Use in AI Agent Node

1. Add an **AI Agent** node to your workflow
2. Connect an **OpenAI Chat Model** sub-node
3. Select your TensorX credential
4. Configure the model:

| Setting         | Recommended Value    |
| --------------- | -------------------- |
| **Model**       | `z-ai/glm-5.2`       |
| **Temperature** | `0.7` (or as needed) |
| **Max Tokens**  | `4096`               |

### Step 3: Test Your Setup

Create a simple test workflow:

```
Manual Trigger → AI Agent → Output
```

Example prompt: "Explain quantum computing in simple terms"

***

## Method 2: HTTP Request Node (Advanced)

For full control over API calls or using features not exposed in the OpenAI node.

### Chat Completion Request

Add an **HTTP Request** node with these settings:

**Request Configuration:**

| Field          | Value                                        |
| -------------- | -------------------------------------------- |
| Method         | `POST`                                       |
| URL            | `https://api.tensorx.ai/v1/chat/completions` |
| Authentication | Header Auth                                  |

**Headers:**

| Header        | Value                 |
| ------------- | --------------------- |
| Authorization | `Bearer YOUR_API_KEY` |
| Content-Type  | `application/json`    |

**Body (JSON):**

```json
{
  "model": "z-ai/glm-5.2",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user", 
      "content": "{{ $json.userMessage }}"
    }
  ],
  "max_tokens": 1000,
  "temperature": 0.7
}
```

### Extract the Response

Add a **Code** node after the HTTP Request:

```javascript
const response = $input.first().json;
const aiMessage = response.choices[0].message.content;

return [{
  json: {
    response: aiMessage,
    model: response.model,
    tokens: response.usage
  }
}];
```

***

## Method 3: Custom n8n Credential (Pro Tip)

Create a reusable HTTP credential for TensorX:

1. Go to **Credentials** → **Add Credential**
2. Select **Header Auth**
3. Configure:

| Field | Value                 |
| ----- | --------------------- |
| Name  | `tensorx-api`         |
| Name  | `Authorization`       |
| Value | `Bearer YOUR_API_KEY` |

Now use this credential in any HTTP Request node targeting `https://api.tensorx.ai`.

***

## Example Workflows

### 1. Email Classifier Agent

Automatically classify incoming emails and route them:

```
Email Trigger (IMAP)
    ↓
AI Agent (TensorX)
    ↓
Switch (by classification)
    ↓
├── Support → Create Ticket
├── Sales → Forward to Sales
└── Spam → Archive
```

**System Prompt:**

```
You are an email classifier. Analyze the email and respond with exactly one of:
- SUPPORT (customer service issues)
- SALES (product inquiries, pricing)
- SPAM (promotional, unwanted)
- OTHER (everything else)

Email content: {{ $json.text }}
```

### 2. Content Generator Pipeline

Generate blog posts from topics:

```
Webhook
    ↓
AI Agent (Generate Outline)
    ↓
Loop Over Items
    ↓
AI Agent (Write Section)
    ↓
Merge
    ↓
Google Docs (Create)
```

### 3. RAG-Powered Support Bot

Build a knowledge-based chatbot:

```
Chat Trigger
    ↓
Pinecone (Search)
    ↓
AI Agent (with context)
    ↓
Respond to Chat
```

**System Prompt:**

```
You are a support assistant. Answer questions using ONLY the provided context.
If the answer isn't in the context, say "I don't have information about that."

Context:
{{ $json.searchResults }}

Question: {{ $json.userQuestion }}
```

### 4. Slack AI Assistant

```
Slack Trigger (message)
    ↓
AI Agent (TensorX)
    ↓
Slack (reply)
```

***

## Recommended Models

| Use Case              | Model                         | Notes                               |
| --------------------- | ----------------------------- | ----------------------------------- |
| **General AI Agent**  | `z-ai/glm-5.2`                | Best balance of capability and cost |
| **Complex Reasoning** | `deepseek/deepseek-r1-0528`   | For multi-step analysis             |
| **Code Generation**   | `z-ai/glm-5.1`                | Optimized for coding tasks          |
| **Long Documents**    | `meta-llama/llama-4-maverick` | Long document processing            |
| **Tool Calling**      | `z-ai/glm-5.2`                | Strong function calling support     |

***

## Troubleshooting

### "Invalid API Key" Error

* Verify your API key is correct
* Ensure you're using the full key (starts with `tn_` or similar)
* Check that Base URL is exactly `https://api.tensorx.ai/v1`

### Model Not Found

* Use the full model identifier (e.g., `z-ai/glm-5.2`)
* Check [available models](https://tensorx.ai/models) for exact names

### Timeout Errors

* Increase timeout in HTTP Request node options
* Consider using streaming for long responses
* For reasoning models, set timeout to 120+ seconds

### Rate Limits

If you hit rate limits:

1. Add a **Wait** node between API calls
2. Use the **Split in Batches** node for bulk processing
3. Implement retry logic with the **Error Trigger**

***

## Best Practices

1. **Use System Prompts** - Always include clear instructions
2. **Set Temperature Appropriately** - Lower (0.3) for factual, higher (0.8) for creative
3. **Limit Max Tokens** - Prevent unexpectedly long responses
4. **Cache Responses** - Store results to avoid redundant API calls
5. **Handle Errors Gracefully** - Use Error Trigger for fallbacks
6. **Secure Credentials** - Never expose API keys in workflow data

***

## See Also

* [API Reference](/api-reference/overview) - Complete API documentation
* [Models](/api-reference/models) - Available models and capabilities
* [n8n AI Documentation](https://docs.n8n.io/advanced-ai/) - Official n8n AI guides


# Make.com

Integrate TensorX AI models with Make.com (formerly Integromat) to build powerful automated scenarios.

***

## Overview

[Make.com](https://www.make.com/) is a visual automation platform that connects thousands of apps. With TensorX's OpenAI-compatible API, you can add AI capabilities to any Make scenario.

### What You Can Build

* 📧 **Email Automation** - Auto-reply, summarize, and classify emails
* 🔄 **Data Enrichment** - Enhance records with AI-generated insights
* 📱 **Social Media Bots** - Generate and schedule content
* 📊 **Report Generation** - Create summaries from data
* 🛒 **E-commerce** - Product descriptions, review analysis
* 📞 **Customer Support** - Intelligent ticket routing and responses

***

## Prerequisites

* Make.com account (Free tier works)
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

***

## Method 1: OpenAI Module with Custom Endpoint

Make's OpenAI module supports custom API endpoints, making TensorX integration simple.

### Step 1: Create OpenAI Connection

1. In Make, go to **Connections**
2. Click **Create a connection**
3. Search for **OpenAI**
4. Configure the connection:

| Field               | Value                |
| ------------------- | -------------------- |
| **Connection Name** | `TensorX AI`         |
| **API Key**         | Your TensorX API key |
| **Organization ID** | Leave empty          |

### Step 2: Override the Base URL

When configuring an OpenAI module, expand **Show advanced settings**:

| Setting               | Value                       |
| --------------------- | --------------------------- |
| **Override Base URL** | ✅ Enabled                   |
| **Base URL**          | `https://api.tensorx.ai/v1` |

### Step 3: Configure the Request

For a **Create a Chat Completion** action:

| Field           | Value                     |
| --------------- | ------------------------- |
| **Model**       | `z-ai/glm-5.2`            |
| **Messages**    | Add your conversation     |
| **Max Tokens**  | `1000` (adjust as needed) |
| **Temperature** | `0.7`                     |

***

## Method 2: HTTP Module (Full Control)

For complete flexibility, use Make's HTTP module.

### Create Chat Completion

Add an **HTTP > Make a request** module:

**Configuration:**

| Field      | Value                                        |
| ---------- | -------------------------------------------- |
| **URL**    | `https://api.tensorx.ai/v1/chat/completions` |
| **Method** | `POST`                                       |

**Headers:**

| Key             | Value                 |
| --------------- | --------------------- |
| `Authorization` | `Bearer YOUR_API_KEY` |
| `Content-Type`  | `application/json`    |

**Body Type:** Raw

**Request Content:**

```json
{
  "model": "z-ai/glm-5.2",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "{{1.userInput}}"
    }
  ],
  "max_tokens": 1000,
  "temperature": 0.7
}
```

**Parse Response:** ✅ Yes

### Extract the AI Response

Access the response in subsequent modules:

```
{{2.choices[1].message.content}}
```

Or use a **JSON > Parse JSON** module for structured access.

***

## Method 3: Reusable HTTP Connection

Create a connection you can reuse across scenarios:

1. Go to **Connections** → **Create a connection**
2. Select **HTTP** → **Make a request**
3. Choose **API Key** authentication:

| Field                | Value                 |
| -------------------- | --------------------- |
| **API Key**          | Your TensorX API key  |
| **Add to**           | Header                |
| **Key Name**         | `Authorization`       |
| **Key Value Prefix** | `Bearer` (with space) |

4. Save as `TensorX API`

Now use this connection in any HTTP module targeting `https://api.tensorx.ai`.

***

## Example Scenarios

### 1. Email Auto-Responder

Automatically draft responses to incoming emails:

```
Gmail (Watch Emails)
    ↓
OpenAI (Create Completion)
    ↓
Gmail (Create Draft)
```

**Prompt Template:**

```
You are an email assistant. Draft a professional response to this email:

From: {{1.from.text}}
Subject: {{1.subject}}
Body: {{1.text}}

Draft a helpful, concise response.
```

### 2. Shopify Product Description Generator

Generate SEO-optimized descriptions for new products:

```
Shopify (Watch Products)
    ↓
OpenAI (Create Completion)
    ↓
Shopify (Update Product)
```

**Prompt:**

```
Write an engaging product description for:
Product: {{1.title}}
Vendor: {{1.vendor}}
Tags: {{1.tags}}

Include benefits, features, and a call-to-action. Keep it under 200 words. Use SEO-friendly language.
```

### 3. Slack Support Bot

Respond to Slack messages with AI:

```
Slack (Watch Messages)
    ↓
Filter (exclude bot messages)
    ↓
OpenAI (Create Completion)
    ↓
Slack (Create a Message)
```

### 4. Lead Enrichment

Enrich CRM leads with AI-generated insights:

```
CRM (New Lead)
    ↓
HTTP (Company lookup)
    ↓
OpenAI (Analyze company)
    ↓
CRM (Update Lead)
```

**Prompt:**

```
Based on this company information, provide:
1. Industry classification
2. Company size estimate
3. Potential use cases for our product
4. Recommended approach

Company: {{1.company_name}}
Website: {{2.website_content}}
```

### 5. Content Calendar Automation

Generate a week's worth of social content:

```
Schedule (Weekly)
    ↓
Iterator (7 days)
    ↓
OpenAI (Generate post)
    ↓
Array Aggregator
    ↓
Google Sheets (Add rows)
```

***

## Working with Responses

### Parse the JSON Response

Make automatically parses JSON responses. Access fields like:

| Field         | Make Syntax                        |
| ------------- | ---------------------------------- |
| AI Response   | `{{X.choices[1].message.content}}` |
| Model Used    | `{{X.model}}`                      |
| Total Tokens  | `{{X.usage.total_tokens}}`         |
| Finish Reason | `{{X.choices[1].finish_reason}}`   |

### Handle Multiple Messages

For multi-turn conversations, use an **Array Aggregator** to build the messages array:

```json
{
  "messages": {{arrayAggregator.messages}}
}
```

***

## Recommended Models

| Scenario Type          | Recommended Model                   |
| ---------------------- | ----------------------------------- |
| **General Text**       | `z-ai/glm-5.2`                      |
| **Analysis/Reasoning** | `deepseek/deepseek-r1-0528`         |
| **Code Generation**    | `z-ai/glm-5.1`                      |
| **Long Documents**     | `meta-llama/llama-4-maverick`       |
| **Quick Responses**    | `meta-llama/llama-3.3-70b-instruct` |

***

## Error Handling

### Add Error Handlers

Right-click any module → **Add error handler**

Recommended handlers:

* **Resume** - Continue with default value
* **Rollback** - Undo changes and retry
* **Break** - Stop and notify

### Common Errors

| Error            | Solution                       |
| ---------------- | ------------------------------ |
| 401 Unauthorized | Check API key is correct       |
| 404 Not Found    | Verify model name exactly      |
| 429 Rate Limited | Add delay between operations   |
| 500 Server Error | Retry with exponential backoff |

### Rate Limit Handling

Use the **Sleep** module between API calls:

```
API Call → Sleep (1 second) → Next API Call
```

For batch processing, use **Iterator** with built-in delay.

***

## Best Practices

### 1. Use Variables for API Key

Store your API key in a scenario variable:

* Go to **Scenario settings** → **Variables**
* Add `tensorx_api_key`
* Reference as `{{tensorx_api_key}}`

### 2. Optimize Token Usage

* Set appropriate `max_tokens` limits
* Use concise system prompts
* Summarize long inputs before processing

### 3. Structure Your Prompts

```
[ROLE]
You are a [specific role].

[TASK]
[Clear instruction]

[FORMAT]
Respond in [format].

[INPUT]
{{input_data}}
```

### 4. Monitor Usage

Add a **Webhook** or **Google Sheets** module to log:

* Token usage per request
* Response times
* Error rates

***

## Pricing Considerations

TensorX charges per token. Optimize costs by:

* Using smaller context when possible
* Caching repeated queries
* Choosing appropriate models for each task
* Setting reasonable max\_tokens limits

***

## See Also

* [API Reference](/api-reference/overview) - Full API documentation
* [Models](/api-reference/models) - Model capabilities and pricing
* [Make.com Documentation](https://www.make.com/en/help) - Official Make guides


# Zapier

Connect TensorX AI to 6,000+ apps with Zapier, the world's most popular automation platform.

***

## Overview

[Zapier](https://zapier.com/) connects apps and automates workflows without code. Using TensorX's OpenAI-compatible API with Zapier's webhooks, you can add AI to any Zap.

### What You Can Build

* 📧 **Smart Email Responses** - Auto-draft replies based on content
* 📋 **Form Processing** - Analyze and route form submissions
* 🏷️ **Content Tagging** - Auto-categorize documents and records
* 📊 **Report Summaries** - Generate insights from data
* 🛒 **E-commerce Automation** - Product content, review analysis
* 💬 **Multi-Channel Bots** - Respond across Slack, Discord, email

***

## Prerequisites

* Zapier account (Free tier works, Webhooks require paid plan)
* TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

***

## Method 1: Webhooks by Zapier (Recommended)

The most flexible way to call TensorX from Zapier.

### Step 1: Create a New Zap

1. Click **Create Zap**
2. Choose your trigger (e.g., New Email in Gmail)
3. Add an action step

### Step 2: Add Webhooks Action

1. Search for **Webhooks by Zapier**
2. Select **POST** as the action event
3. Configure the webhook:

**URL:**

```
https://api.tensorx.ai/v1/chat/completions
```

**Payload Type:** `json`

**Data:**

```
model: z-ai/glm-5.2
messages: [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Your prompt here"}]
max_tokens: 1000
temperature: 0.7
```

**Headers:**

| Key             | Value                 |
| --------------- | --------------------- |
| `Authorization` | `Bearer YOUR_API_KEY` |
| `Content-Type`  | `application/json`    |

### Step 3: Use Dynamic Content

Replace the user message with data from your trigger:

```
messages: [{"role": "user", "content": "Summarize this email: {{body}}"}]
```

### Step 4: Extract the Response

Add a **Formatter by Zapier** action:

* Action: **Text** → **Split Text**
* Input: `{{webhooks__choices__0__message__content}}`
* Separator: (leave empty for full text)

Or use **Code by Zapier** for more control:

```javascript
const response = JSON.parse(inputData.webhookResponse);
return { aiMessage: response.choices[0].message.content };
```

***

## Method 2: OpenAI App (With Custom Base URL)

If Zapier's OpenAI integration supports custom endpoints:

### Setup

1. Add **OpenAI** as an action
2. In connection settings, look for **Advanced** or **Custom Base URL**
3. Enter: `https://api.tensorx.ai/v1`
4. Use your TensorX API key

> **Note:** This method depends on Zapier's OpenAI integration supporting custom URLs. If not available, use the Webhooks method above.

***

## Method 3: Code by Zapier

For complex logic, use JavaScript or Python:

### JavaScript Example

```javascript
const response = await fetch('https://api.tensorx.ai/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${inputData.apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'z-ai/glm-5.2',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: inputData.prompt }
    ],
    max_tokens: 1000
  })
});

const data = await response.json();
return { response: data.choices[0].message.content };
```

### Python Example

```python
import requests

response = requests.post(
    'https://api.tensorx.ai/v1/chat/completions',
    headers={
        'Authorization': f'Bearer {input_data["api_key"]}',
        'Content-Type': 'application/json'
    },
    json={
        'model': 'z-ai/glm-5.2',
        'messages': [
            {'role': 'user', 'content': input_data['prompt']}
        ],
        'max_tokens': 1000
    }
)

result = response.json()
return {'response': result['choices'][0]['message']['content']}
```

***

## Example Zaps

### 1. Email Auto-Classifier

Automatically label and route incoming emails:

```
Gmail (New Email)
    ↓
Webhooks (POST to TensorX)
    ↓
Paths (by AI classification)
    ├── Support → Zendesk
    ├── Sales → Pipedrive
    └── Other → Slack notification
```

**Prompt:**

```
Classify this email into exactly one category: SUPPORT, SALES, BILLING, SPAM, or OTHER.

From: {{from_email}}
Subject: {{subject}}
Body: {{body}}

Respond with only the category name.
```

### 2. Form Response Analyzer

Analyze feedback forms and extract insights:

```
Typeform (New Response)
    ↓
Webhooks (POST to TensorX)
    ↓
Google Sheets (Add Row)
    ↓
Slack (Send if negative sentiment)
```

**Prompt:**

```
Analyze this feedback and provide:
1. Sentiment (Positive/Neutral/Negative)
2. Key topics mentioned (comma-separated)
3. One-line summary

Feedback: {{answers}}
```

### 3. Content Generator

Generate social posts from blog articles:

```
RSS (New Item)
    ↓
Webhooks (POST to TensorX)
    ↓
Buffer (Create Post)
```

**Prompt:**

```
Create a Twitter post promoting this article. Keep it under 280 characters. Include a hook and call-to-action.

Title: {{title}}
Summary: {{description}}
```

### 4. Lead Scoring

Score new leads based on their data:

```
CRM (New Lead)
    ↓
Webhooks (POST to TensorX)
    ↓
Formatter (Extract score)
    ↓
CRM (Update Lead)
```

**Prompt:**

```
Score this lead from 1-100 based on:
- Company size (larger = higher)
- Job title seniority
- Industry fit

Company: {{company}}
Title: {{job_title}}
Industry: {{industry}}
Employees: {{company_size}}

Respond with ONLY the numeric score.
```

### 5. Meeting Notes Processor

Transform raw notes into structured summaries:

```
Calendar (Event End)
    ↓
Webhooks (POST to TensorX)
    ↓
Notion (Create Page)
    ↓
Slack (Share summary)
```

**Prompt:**

```
Convert these meeting notes into a structured summary:

# {{event_title}}
Date: {{event_date}}

## Attendees
[List attendees]

## Key Points
[Bullet points of main discussion items]

## Action Items
[Tasks with owners if mentioned]

## Decisions Made
[Any decisions reached]

Notes: {{notes}}
```

***

## Working with Responses

### Access Response Fields

After the webhook, use Zapier's built-in parsing:

| What You Need | Zapier Field Path              |
| ------------- | ------------------------------ |
| AI Response   | `choices__0__message__content` |
| Model         | `model`                        |
| Total Tokens  | `usage__total_tokens`          |

### Clean Up Output

Use **Formatter by Zapier**:

1. **Trim Whitespace** - Remove extra spaces
2. **Replace** - Clean unwanted characters
3. **Split Text** - Extract specific parts

***

## Recommended Models

| Task                 | Model                               | Why                  |
| -------------------- | ----------------------------------- | -------------------- |
| **Classification**   | `z-ai/glm-5.2`                      | Fast, accurate       |
| **Summarization**    | `meta-llama/llama-3.3-70b-instruct` | Good compression     |
| **Analysis**         | `deepseek/deepseek-r1-0528`         | Deep reasoning       |
| **Content Creation** | `z-ai/glm-5.2`                      | Creative, coherent   |
| **Code Tasks**       | `z-ai/glm-5.1`                      | Excellent for coding |

***

## Error Handling

### Handle API Errors

Add a **Paths** step after your webhook:

* **Path A:** Webhook successful (status = 200)
* **Path B:** Error occurred → Send alert

### Common Issues

| Error   | Cause           | Fix                          |
| ------- | --------------- | ---------------------------- |
| 401     | Invalid API key | Check key in webhook headers |
| 400     | Malformed JSON  | Validate your JSON structure |
| 429     | Rate limited    | Add delay between steps      |
| Timeout | Long response   | Increase webhook timeout     |

### Retry Logic

Use Zapier's built-in retry:

1. Click the webhook step
2. Go to **Advanced**
3. Enable **Retry** on failure

***

## Best Practices

### 1. Store API Key Securely

* Use Zapier's **App Connections** when possible
* Never expose keys in Zap names or descriptions

### 2. Optimize for Speed

* Use concise prompts
* Set appropriate `max_tokens`
* Choose faster models for simple tasks

### 3. Handle Long Text

For content exceeding limits:

```
Formatter (Truncate) → Webhook → Response
```

### 4. Test Thoroughly

* Use Zapier's **Test** feature
* Check edge cases (empty fields, special characters)

### 5. Monitor Usage

Add a logging step to track:

* Token consumption
* Response times
* Error rates

***

## Pricing Notes

* **Zapier:** Webhooks require a paid plan
* **TensorX:** Pay per token used

Optimize costs by:

* Caching repeated requests
* Using smaller models for simple tasks
* Batching related operations

***

## See Also

* [API Reference](/api-reference/overview) - Complete API documentation
* [Models](/api-reference/models) - Available models
* [Zapier Help](https://help.zapier.com/) - Official Zapier documentation


# Flowise

Flowise is a low-code visual tool for building LLM applications and AI agents using a drag-and-drop interface.

## Prerequisites

* A Flowise instance (self-hosted or cloud)
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Flowise connects to TensorX through the **ChatOpenAI Custom** node, which allows you to specify a custom OpenAI-compatible endpoint.

### Step 1: Add ChatOpenAI Custom Node

1. Open your Flowise canvas
2. In the left sidebar, navigate to **Chat Models**
3. Drag the **ChatOpenAI Custom** node onto your canvas

### Step 2: Configure the Node

Configure the ChatOpenAI Custom node with these settings:

| Parameter      | Value                       |
| -------------- | --------------------------- |
| **Base Path**  | `https://api.tensorx.ai/v1` |
| **Model Name** | `z-ai/glm-5.2`              |

{% hint style="info" %}
Use the full model ID including the provider prefix (e.g., `z-ai/glm-5.2`, `z-ai/glm-5.1`).
{% endhint %}

### Step 3: Create API Credential

1. Click the **Credential** field and select **Create New**
2. Select **OpenAI API** as the credential type
3. Enter your TensorX API key
4. Save the credential

### Step 4: Adjust Optional Parameters

You can customize these optional settings:

| Parameter       | Description                | Default       |
| --------------- | -------------------------- | ------------- |
| **Temperature** | Controls randomness (0-1)  | 0.7           |
| **Max Tokens**  | Maximum response length    | Model default |
| **Streaming**   | Enable streaming responses | true          |

## Example Configurations

### General Chat

```
Base Path: https://api.tensorx.ai/v1
Model Name: z-ai/glm-5.2
Temperature: 0.7
```

### Code Generation

For code-related tasks, use a coding-optimized model:

```
Base Path: https://api.tensorx.ai/v1
Model Name: z-ai/glm-5.1
Temperature: 0.3
```

{% hint style="info" %}
**Recommended Coding Models:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

### Reasoning Tasks

```
Base Path: https://api.tensorx.ai/v1
Model Name: minimax/minimax-m2.5
Temperature: 0.5
```

## Building a Chatflow

Here's how to create a basic chatflow with TensorX:

1. Add a **ChatOpenAI Custom** node and configure as shown above
2. Add a **Chat Input** node
3. Connect Chat Input → ChatOpenAI Custom
4. Add a **Chat Output** node
5. Connect ChatOpenAI Custom → Chat Output
6. Click **Save Chatflow**

## Building an AI Agent

To create an agent with tools:

1. Add a **ChatOpenAI Custom** node configured for TensorX
2. Add an **Agent** node (e.g., OpenAI Functions Agent)
3. Connect your model to the Agent's LLM input
4. Add tool nodes (Calculator, Web Search, etc.)
5. Connect tools to the Agent
6. Add Chat Input and Chat Output nodes

{% hint style="warning" %}
For agent workflows that require tool calling, use `z-ai/glm-5.1` as it has the best tool calling support.
{% endhint %}

## Available Models

Browse all available models at [app.tensorx.ai/models](https://app.tensorx.ai/models).

| Model ID               | Best For                           |
| ---------------------- | ---------------------------------- |
| `z-ai/glm-5.2`         | General chat, balanced performance |
| `z-ai/glm-5.1`         | Tool calling, code generation      |
| `minimax/minimax-m2.5` | Reasoning, functions               |
| `moonshotai/kimi-k2.5` | Vision, long context               |
| `openai/gpt-4.1`       | Premium quality                    |

## Troubleshooting

### "Invalid API Key" Error

* Verify your API key at [app.tensorx.ai](https://app.tensorx.ai)
* Ensure the credential type is set to **OpenAI API**
* Check that the Base Path is exactly `https://api.tensorx.ai/v1`

### "Model Not Found" Error

* Use the full model ID including the provider (e.g., `z-ai/glm-5.2`)
* Check available models at [app.tensorx.ai/models](https://app.tensorx.ai/models)

### Streaming Issues

If responses are slow or not streaming:

* Enable the **Streaming** option in the node settings
* Ensure your Flowise version supports streaming

## Support

Need help? Contact us at <support@tensorx.ai>


# Dify

Dify is an open-source LLMOps platform for building AI applications, chatbots, and agents with a visual workflow interface.

## Prerequisites

* A Dify instance (self-hosted or [Dify Cloud](https://cloud.dify.ai))
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Dify connects to TensorX through the **OpenAI API Compatible** plugin, which supports custom OpenAI-compatible endpoints.

### Step 1: Install the Plugin

1. Go to your Dify workspace
2. Navigate to **Plugins** in the left sidebar
3. Search for **OpenAI API Compatible**
4. Click **Install** to add the plugin

{% hint style="info" %}
The OpenAI API Compatible plugin is an official Dify plugin that supports LLMs, text embedding, speech-to-text, and text-to-speech from OpenAI-compatible providers.
{% endhint %}

### Step 2: Add Model Provider

1. Go to **Settings** → **Model Providers**
2. Find **OpenAI API Compatible** in the list
3. Click **Add Model**

### Step 3: Configure the Model

Fill in the configuration form:

| Field                | Value                       |
| -------------------- | --------------------------- |
| **Model Type**       | `LLM`                       |
| **Model Name**       | `z-ai/glm-5.2`              |
| **API Key**          | Your TensorX API key        |
| **API Endpoint URL** | `https://api.tensorx.ai/v1` |

Click **Save** to add the model.

### Step 4: Add More Models (Optional)

Repeat Step 3 to add additional TensorX models:

| Model Name             | Best For                      |
| ---------------------- | ----------------------------- |
| `z-ai/glm-5.1`         | Tool calling, code generation |
| `minimax/minimax-m2.5` | Reasoning, functions          |
| `moonshotai/kimi-k2.5` | Vision, long context          |

## Using TensorX Models

### In Chat Applications

1. Create a new **Chatbot** or **Agent** application
2. In the orchestration panel, click the model selector
3. Select your configured TensorX model
4. Adjust parameters (temperature, max tokens) as needed

### In Workflows

1. Create a new **Workflow** application
2. Add an **LLM** node to your workflow
3. Select your TensorX model from the dropdown
4. Configure the prompt and parameters

## Recommended Models

{% hint style="info" %}
**For Coding Tasks:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

| Model ID               | Use Case                             |
| ---------------------- | ------------------------------------ |
| `z-ai/glm-5.2`         | General chat, balanced performance   |
| `z-ai/glm-5.1`         | Tool calling, function calling, code |
| `minimax/minimax-m2.5` | Reasoning, analysis, complex tasks   |
| `moonshotai/kimi-k2.5` | Vision tasks, long context           |

## Advanced Configuration

### Adding Embedding Models

To use TensorX for text embeddings:

1. Go to **Settings** → **Model Providers**
2. Click **Add Model** under OpenAI API Compatible
3. Set **Model Type** to `Text Embedding`
4. Enter the embedding model name
5. Configure API key and endpoint URL

### Adding Speech Models

For text-to-speech or speech-to-text:

1. Add a new model with type `TTS` or `Speech2Text`
2. Use the appropriate TensorX audio model
3. Configure API key and endpoint URL

## Agent Configuration

When building agents that use tools:

1. Select `z-ai/glm-5.1` as your model (best tool calling support)
2. Enable **Function Calling** in the agent settings
3. Add your desired tools from the Dify tool library
4. Configure tool permissions and parameters

## Example: Building a Code Assistant

1. Create a new **Agent** application
2. Select `z-ai/glm-5.1` as the model
3. Add a system prompt:

   ```
   You are an expert programming assistant. Help users write, debug, and explain code.
   ```
4. Enable tools like **Code Interpreter** if available
5. Set temperature to `0.3` for more deterministic outputs
6. Publish your application

## Troubleshooting

### "Model Not Found" Error

* Ensure you're using the full model ID (e.g., `z-ai/glm-5.2`)
* Verify the API Endpoint URL is exactly `https://api.tensorx.ai/v1`

### "Authentication Failed" Error

* Check that your API key is correct
* Verify the key at [app.tensorx.ai](https://app.tensorx.ai)
* Ensure there are no extra spaces in the API key field

### Model Not Appearing in Selector

* Confirm the plugin is installed and enabled
* Check that the model was saved successfully in Model Providers
* Refresh the page or restart the application

### Slow Responses

* Check your Dify instance's network connection
* Consider using a model with faster response times
* Enable streaming in the application settings

## Support

Need help? Contact us at <support@tensorx.ai>


# Langflow

Langflow is a visual framework for building RAG applications and multi-agent AI workflows using a drag-and-drop interface.

## Prerequisites

* A Langflow instance (self-hosted or [Langflow Cloud](https://astra.datastax.com/langflow))
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Langflow connects to TensorX through the **OpenAI** model component, which supports custom base URLs for OpenAI-compatible APIs.

### Step 1: Add OpenAI Model Component

1. Open your Langflow workspace
2. In the component sidebar, navigate to **Models**
3. Drag the **OpenAI** component onto your canvas

### Step 2: Configure the Component

Click on the OpenAI component to open its settings and configure:

| Parameter           | Value                       |
| ------------------- | --------------------------- |
| **OpenAI API Base** | `https://api.tensorx.ai/v1` |
| **OpenAI API Key**  | Your TensorX API key        |
| **Model Name**      | `z-ai/glm-5.2`              |

{% hint style="info" %}
The **OpenAI API Base** field allows you to point to any OpenAI-compatible endpoint. Enter the full URL including `/v1`.
{% endhint %}

### Step 3: Adjust Model Parameters

Configure optional parameters as needed:

| Parameter       | Description                | Recommended |
| --------------- | -------------------------- | ----------- |
| **Temperature** | Controls randomness (0-2)  | 0.7         |
| **Max Tokens**  | Maximum response length    | 4096        |
| **Stream**      | Enable streaming responses | true        |

## Building a Basic Flow

### Simple Chat Flow

1. Add an **OpenAI** model component (configured for TensorX)
2. Add a **Chat Input** component
3. Add a **Chat Output** component
4. Connect: Chat Input → OpenAI → Chat Output
5. Click **Run** to test

### RAG Flow with Vector Store

1. Add an **OpenAI** model component for TensorX
2. Add a **Vector Store** component (Chroma, Pinecone, etc.)
3. Add a **Retriever** component
4. Add a **Prompt** component with RAG template
5. Connect components to build the retrieval pipeline
6. Add Chat Input/Output for interaction

## Recommended Models

{% hint style="info" %}
**For Coding Tasks:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

| Model ID               | Best For                   |
| ---------------------- | -------------------------- |
| `z-ai/glm-5.2`         | General chat, balanced     |
| `z-ai/glm-5.1`         | Tool calling, agents, code |
| `minimax/minimax-m2.5` | Reasoning, functions       |
| `moonshotai/kimi-k2.5` | Vision, long context       |

## Agent Workflows

When building agent workflows with tools:

### Step 1: Configure Model for Tool Calling

Use `z-ai/glm-5.1` for best tool calling support:

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: z-ai/glm-5.1
Temperature: 0.3
```

### Step 2: Add Tool Components

1. Add tool components from the **Tools** section
2. Available tools include: Calculator, Web Search, Python Code, etc.
3. Connect tools to your agent flow

### Step 3: Build Agent Logic

1. Add an **Agent** component
2. Connect your TensorX model to the agent's LLM input
3. Connect tool components to the agent
4. Add memory component if needed for conversation history

## Example Configurations

### Code Assistant

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: z-ai/glm-5.1
Temperature: 0.2
Max Tokens: 8192
```

### Creative Writing

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: z-ai/glm-5.2
Temperature: 0.9
Max Tokens: 4096
```

### Analytical Tasks

```
OpenAI API Base: https://api.tensorx.ai/v1
Model Name: minimax/minimax-m2.5
Temperature: 0.4
Max Tokens: 4096
```

## Using Multiple Models

You can use different TensorX models in the same flow:

1. Add multiple **OpenAI** components
2. Configure each with a different model
3. Use a **Router** component to direct queries to the appropriate model
4. Or chain models for multi-step processing

## Memory and Context

### Adding Conversation Memory

1. Add a **Memory** component (e.g., Buffer Memory)
2. Connect it to your OpenAI model component
3. This enables multi-turn conversations with context

### Managing Context Length

For long conversations:

* Use models with larger context windows
* Implement summarization for older messages
* Use the Memory component's built-in truncation

## Troubleshooting

### "Invalid API Key" Error

* Verify your API key at [app.tensorx.ai](https://app.tensorx.ai)
* Check for extra spaces in the API key field
* Ensure the base URL is correct: `https://api.tensorx.ai/v1`

### "Model Not Found" Error

* Use the full model ID with provider prefix
* Example: `z-ai/glm-5.2` not just `glm-5.2`
* Check available models at [app.tensorx.ai/models](https://app.tensorx.ai/models)

### Connection Timeout

* Check your Langflow instance's network connectivity
* Verify there are no firewall rules blocking the API
* Try increasing timeout settings if available

### Flow Not Responding

* Check the Langflow logs for error messages
* Verify all required connections are made
* Test individual components before full flow

## Support

Need help? Contact us at <support@tensorx.ai>


# Activepieces

Activepieces is an open-source automation platform similar to Zapier, with a visual workflow builder for connecting apps and services.

## Prerequisites

* An Activepieces instance (self-hosted or cloud)
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Since the built-in OpenAI piece uses a hardcoded endpoint, you'll use the **HTTP Request** piece to connect to TensorX's OpenAI-compatible API.

{% hint style="info" %}
The HTTP Request method gives you full control over the API call and works with any OpenAI-compatible endpoint.
{% endhint %}

## Method: HTTP Request Piece

### Step 1: Add HTTP Request Piece

1. Open your Activepieces flow
2. Click **+** to add a new piece
3. Search for **HTTP** and select **HTTP Request (Advanced)**

### Step 2: Configure the Request

Set up the HTTP request with these parameters:

| Field      | Value                                        |
| ---------- | -------------------------------------------- |
| **Method** | `POST`                                       |
| **URL**    | `https://api.tensorx.ai/v1/chat/completions` |

### Step 3: Add Headers

Click **Add Header** and add the following:

| Header          | Value                         |
| --------------- | ----------------------------- |
| `Authorization` | `Bearer YOUR_TENSORX_API_KEY` |
| `Content-Type`  | `application/json`            |

### Step 4: Configure the Body

Set **Body Type** to `Raw (JSON)` and enter:

```json
{
  "model": "z-ai/glm-5.2",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "{{trigger.message}}"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 1000
}
```

{% hint style="info" %}
Replace `{{trigger.message}}` with your actual data source from previous pieces in your flow.
{% endhint %}

### Step 5: Parse the Response

The API returns a JSON response. To extract the assistant's message:

1. Add a **Code** piece after the HTTP Request
2. Use JavaScript to parse the response:

```javascript
const response = inputs.httpResponse.body;
return {
  message: response.choices[0].message.content,
  model: response.model,
  tokens: response.usage.total_tokens
};
```

## Example Flows

### Email Summarizer

1. **Trigger**: New Email (Gmail piece)
2. **HTTP Request**: Send email body to TensorX for summarization
3. **Action**: Save summary to Notion or send to Slack

Request body:

```json
{
  "model": "z-ai/glm-5.2",
  "messages": [
    {
      "role": "system",
      "content": "Summarize the following email in 2-3 sentences."
    },
    {
      "role": "user",
      "content": "{{trigger.emailBody}}"
    }
  ],
  "temperature": 0.3,
  "max_tokens": 200
}
```

### Customer Support Classifier

1. **Trigger**: New Support Ticket (webhook or integration)
2. **HTTP Request**: Classify ticket category
3. **Branch**: Route based on category
4. **Action**: Assign to appropriate team

Request body:

```json
{
  "model": "z-ai/glm-5.1",
  "messages": [
    {
      "role": "system",
      "content": "Classify this support ticket into one of: billing, technical, general, urgent. Return only the category name."
    },
    {
      "role": "user",
      "content": "{{trigger.ticketContent}}"
    }
  ],
  "temperature": 0.1,
  "max_tokens": 20
}
```

### Content Generator

1. **Trigger**: New Row in Google Sheets
2. **HTTP Request**: Generate content based on topic
3. **Action**: Update sheet with generated content

Request body:

```json
{
  "model": "z-ai/glm-5.2",
  "messages": [
    {
      "role": "system",
      "content": "Write a short blog post introduction about the given topic."
    },
    {
      "role": "user",
      "content": "Topic: {{trigger.topic}}"
    }
  ],
  "temperature": 0.8,
  "max_tokens": 500
}
```

## Recommended Models

{% hint style="info" %}
**For Coding Tasks:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

| Model ID               | Best For                          |
| ---------------------- | --------------------------------- |
| `z-ai/glm-5.2`         | General text generation           |
| `z-ai/glm-5.1`         | Classification, structured output |
| `minimax/minimax-m2.5` | Complex reasoning, analysis       |
| `moonshotai/kimi-k2.5` | Vision, long context              |

## Handling Streaming Responses

For long responses, you may want to handle streaming:

1. The TensorX API supports streaming with `"stream": true`
2. However, HTTP Request piece may not handle SSE well
3. For streaming, consider using a webhook-based approach or the Code piece with fetch

## Error Handling

### Add Error Handling

1. Click on your HTTP Request piece
2. Enable **Handle Errors**
3. Add a branch to handle failed requests

### Common Errors

| Error | Cause             | Solution                    |
| ----- | ----------------- | --------------------------- |
| 401   | Invalid API key   | Check your API key          |
| 400   | Malformed request | Verify JSON body format     |
| 404   | Wrong endpoint    | Use `/v1/chat/completions`  |
| 429   | Rate limit        | Add delays between requests |

## Creating a Reusable Template

To reuse your TensorX configuration:

1. Create a flow template with the HTTP Request piece configured
2. Use flow variables for dynamic content
3. Duplicate the template for new automations

## Storing API Key Securely

Instead of hardcoding your API key:

1. Go to **Settings** → **Connections**
2. Create a new **Custom Connection**
3. Store your API key securely
4. Reference it in your flows using `{{connections.tensorx.apiKey}}`

## Troubleshooting

### "Request Failed" Error

* Check the URL is exactly `https://api.tensorx.ai/v1/chat/completions`
* Verify headers are correctly formatted
* Test your API key with a simple curl command

### Empty Response

* Check the response body parsing
* Verify the model ID is correct
* Look at the raw response for error messages

### Timeout Errors

* Increase the timeout setting in HTTP Request piece
* Use a faster model for time-sensitive flows
* Consider breaking long operations into smaller chunks

## Support

Need help? Contact us at <support@tensorx.ai>


# Pipedream

Pipedream is a developer-focused automation platform that combines no-code workflows with the ability to write custom code in Node.js or Python.

## Prerequisites

* A Pipedream account ([pipedream.com](https://pipedream.com))
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Pipedream offers two methods to connect to TensorX:

1. **Code Step** - Write Node.js or Python code (recommended for flexibility)
2. **HTTP Request Action** - No-code approach

## Method 1: Node.js Code Step (Recommended)

### Step 1: Add a Code Step

1. Create a new workflow or open an existing one
2. Click **+** to add a step
3. Select **Node** → **Run Node.js code**

### Step 2: Write the API Call

```javascript
import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    tensorxApiKey: {
      type: "string",
      label: "TensorX API Key",
      secret: true,
    },
  },
  async run({ steps, $ }) {
    const response = await axios($, {
      method: "POST",
      url: "https://api.tensorx.ai/v1/chat/completions",
      headers: {
        "Authorization": `Bearer ${this.tensorxApiKey}`,
        "Content-Type": "application/json",
      },
      data: {
        model: "z-ai/glm-5.2",
        messages: [
          {
            role: "system",
            content: "You are a helpful assistant."
          },
          {
            role: "user",
            content: steps.trigger.event.message // Adjust based on your trigger
          }
        ],
        temperature: 0.7,
        max_tokens: 1000,
      },
    });
    
    return {
      content: response.choices[0].message.content,
      model: response.model,
      usage: response.usage,
    };
  },
});
```

### Step 3: Configure the API Key

1. When you run the workflow, Pipedream will prompt for the API key
2. Enter your TensorX API key
3. The key is stored securely and can be reused

## Method 2: Python Code Step

```python
import requests

def handler(pd: "pipedream"):
    api_key = pd.inputs["tensorx_api_key"]
    user_message = pd.steps["trigger"]["event"]["message"]
    
    response = requests.post(
        "https://api.tensorx.ai/v1/chat/completions",
        headers={
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json",
        },
        json={
            "model": "z-ai/glm-5.2",
            "messages": [
                {"role": "system", "content": "You are a helpful assistant."},
                {"role": "user", "content": user_message}
            ],
            "temperature": 0.7,
            "max_tokens": 1000,
        }
    )
    
    data = response.json()
    return {
        "content": data["choices"][0]["message"]["content"],
        "model": data["model"],
        "usage": data["usage"],
    }
```

## Method 3: HTTP Request Action

For a no-code approach:

1. Click **+** → **HTTP / Webhook** → **Send any HTTP Request**
2. Configure:

| Field      | Value                                        |
| ---------- | -------------------------------------------- |
| **Method** | `POST`                                       |
| **URL**    | `https://api.tensorx.ai/v1/chat/completions` |

3. Add Headers:
   * `Authorization`: `Bearer YOUR_API_KEY`
   * `Content-Type`: `application/json`
4. Set Body to:

```json
{
  "model": "z-ai/glm-5.2",
  "messages": [
    {"role": "user", "content": "{{steps.trigger.event.message}}"}
  ]
}
```

## Example Workflows

### Slack AI Assistant

Trigger: New Slack message in channel Action: Reply with AI-generated response

```javascript
import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    tensorxApiKey: {
      type: "string",
      label: "TensorX API Key",
      secret: true,
    },
  },
  async run({ steps, $ }) {
    // Get the Slack message
    const userMessage = steps.trigger.event.text;
    
    // Skip if it's a bot message
    if (steps.trigger.event.bot_id) {
      return { skipped: true };
    }
    
    // Call TensorX API
    const response = await axios($, {
      method: "POST",
      url: "https://api.tensorx.ai/v1/chat/completions",
      headers: {
        "Authorization": `Bearer ${this.tensorxApiKey}`,
        "Content-Type": "application/json",
      },
      data: {
        model: "z-ai/glm-5.2",
        messages: [
          {
            role: "system",
            content: "You are a helpful Slack assistant. Keep responses concise."
          },
          { role: "user", content: userMessage }
        ],
        temperature: 0.7,
        max_tokens: 500,
      },
    });
    
    return { reply: response.choices[0].message.content };
  },
});
```

### Email Classifier

```javascript
import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    tensorxApiKey: {
      type: "string",
      label: "TensorX API Key",
      secret: true,
    },
  },
  async run({ steps, $ }) {
    const emailSubject = steps.trigger.event.subject;
    const emailBody = steps.trigger.event.body;
    
    const response = await axios($, {
      method: "POST",
      url: "https://api.tensorx.ai/v1/chat/completions",
      headers: {
        "Authorization": `Bearer ${this.tensorxApiKey}`,
        "Content-Type": "application/json",
      },
      data: {
        model: "z-ai/glm-5.1",
        messages: [
          {
            role: "system",
            content: `Classify this email into one category: sales, support, spam, newsletter, personal. 
                      Return JSON: {"category": "...", "priority": "high|medium|low", "summary": "..."}`
          },
          {
            role: "user",
            content: `Subject: ${emailSubject}\n\nBody: ${emailBody}`
          }
        ],
        temperature: 0.1,
        max_tokens: 200,
      },
    });
    
    return JSON.parse(response.choices[0].message.content);
  },
});
```

### Content Generator with Streaming

```javascript
import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    tensorxApiKey: {
      type: "string",
      label: "TensorX API Key",
      secret: true,
    },
  },
  async run({ steps, $ }) {
    const topic = steps.trigger.event.topic;
    
    const response = await axios($, {
      method: "POST",
      url: "https://api.tensorx.ai/v1/chat/completions",
      headers: {
        "Authorization": `Bearer ${this.tensorxApiKey}`,
        "Content-Type": "application/json",
      },
      data: {
        model: "z-ai/glm-5.2",
        messages: [
          {
            role: "system",
            content: "You are a professional content writer."
          },
          {
            role: "user",
            content: `Write a blog post about: ${topic}`
          }
        ],
        temperature: 0.8,
        max_tokens: 2000,
      },
    });
    
    return {
      content: response.choices[0].message.content,
      wordCount: response.choices[0].message.content.split(' ').length,
      tokensUsed: response.usage.total_tokens,
    };
  },
});
```

## Recommended Models

{% hint style="info" %}
**For Coding Tasks:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

| Model ID               | Best For                               |
| ---------------------- | -------------------------------------- |
| `z-ai/glm-5.2`         | General chat, content generation       |
| `z-ai/glm-5.1`         | Classification, structured JSON output |
| `minimax/minimax-m2.5` | Complex reasoning, analysis            |
| `moonshotai/kimi-k2.5` | Vision, long context                   |

## Using Environment Variables

Store your API key securely:

1. Go to **Settings** → **Environment Variables**
2. Add `TENSORX_API_KEY` with your key
3. Access in code: `process.env.TENSORX_API_KEY`

```javascript
const response = await axios($, {
  url: "https://api.tensorx.ai/v1/chat/completions",
  headers: {
    "Authorization": `Bearer ${process.env.TENSORX_API_KEY}`,
  },
  // ...
});
```

## Error Handling

```javascript
try {
  const response = await axios($, {
    method: "POST",
    url: "https://api.tensorx.ai/v1/chat/completions",
    headers: {
      "Authorization": `Bearer ${this.tensorxApiKey}`,
      "Content-Type": "application/json",
    },
    data: {
      model: "z-ai/glm-5.2",
      messages: [{ role: "user", content: "Hello" }],
    },
  });
  return response;
} catch (error) {
  if (error.response?.status === 401) {
    throw new Error("Invalid API key");
  } else if (error.response?.status === 429) {
    throw new Error("Rate limit exceeded");
  }
  throw error;
}
```

## Troubleshooting

### "Unauthorized" Error

* Check that your API key is correct
* Ensure the Authorization header format is `Bearer YOUR_KEY`

### "Model Not Found" Error

* Use the full model ID: `z-ai/glm-5.2`
* Check available models at [app.tensorx.ai/models](https://app.tensorx.ai/models)

### Timeout Errors

* Increase the timeout in axios config: `timeout: 60000`
* Use a faster model for time-sensitive workflows

## Support

Need help? Contact us at <support@tensorx.ai>


# Botpress

Botpress is an open-source platform for building AI-powered chatbots and conversational agents with a visual workflow builder.

## Prerequisites

* A Botpress Cloud account ([app.botpress.cloud](https://app.botpress.cloud))
* Your TensorX API key from [app.tensorx.ai](https://app.tensorx.ai)

## Configuration

Botpress uses the **Execute Code** card to make HTTP requests to external APIs like TensorX. This method gives you full control over the API integration.

{% hint style="info" %}
Botpress has built-in AI models, but you can use the Execute Code card to integrate custom OpenAI-compatible providers like TensorX.
{% endhint %}

## Method: Execute Code Card

### Step 1: Create a Workflow

1. Open your bot in Botpress Studio
2. Create a new workflow or open an existing one
3. Add a node where you want to call the AI

### Step 2: Add Execute Code Card

1. Click **+** to add a new card
2. Select **Execute Code**
3. This opens the code editor

### Step 3: Write the API Call

```javascript
const response = await axios.post(
  'https://api.tensorx.ai/v1/chat/completions',
  {
    model: 'z-ai/glm-5.2',
    messages: [
      {
        role: 'system',
        content: 'You are a helpful customer service assistant.'
      },
      {
        role: 'user',
        content: event.preview // The user's message
      }
    ],
    temperature: 0.7,
    max_tokens: 500
  },
  {
    headers: {
      'Authorization': `Bearer ${env.TENSORX_API_KEY}`,
      'Content-Type': 'application/json'
    }
  }
);

// Store the response in a workflow variable
workflow.aiResponse = response.data.choices[0].message.content;
```

### Step 4: Set Environment Variable

1. Go to **Chatbot Settings** → **Variables**
2. Add a new **Secret** variable named `TENSORX_API_KEY`
3. Paste your TensorX API key

### Step 5: Display the Response

After the Execute Code card:

1. Add a **Text** card
2. Set the content to: `{{workflow.aiResponse}}`

## Building a Complete Chatbot

### Basic AI Chatbot Flow

```
Start → Capture User Input → Execute Code (TensorX) → Display Response → End
```

1. **Start Node**: Entry point of the conversation
2. **Capture**: Stores user message in `event.preview`
3. **Execute Code**: Calls TensorX API
4. **Text Card**: Shows the AI response

### Multi-Turn Conversation

For conversations with memory:

```javascript
// Initialize conversation history if needed
if (!workflow.conversationHistory) {
  workflow.conversationHistory = [];
}

// Add user message to history
workflow.conversationHistory.push({
  role: 'user',
  content: event.preview
});

// Call TensorX API
const response = await axios.post(
  'https://api.tensorx.ai/v1/chat/completions',
  {
    model: 'z-ai/glm-5.2',
    messages: [
      {
        role: 'system',
        content: 'You are a helpful assistant. Maintain context from previous messages.'
      },
      ...workflow.conversationHistory
    ],
    temperature: 0.7,
    max_tokens: 500
  },
  {
    headers: {
      'Authorization': `Bearer ${env.TENSORX_API_KEY}`,
      'Content-Type': 'application/json'
    }
  }
);

const assistantMessage = response.data.choices[0].message.content;

// Add assistant response to history
workflow.conversationHistory.push({
  role: 'assistant',
  content: assistantMessage
});

// Store for display
workflow.aiResponse = assistantMessage;
```

## Example Implementations

### Customer Support Bot

```javascript
const response = await axios.post(
  'https://api.tensorx.ai/v1/chat/completions',
  {
    model: 'z-ai/glm-5.1',
    messages: [
      {
        role: 'system',
        content: `You are a customer support agent for Acme Corp.
        
        Guidelines:
        - Be helpful and professional
        - If you can't answer, suggest contacting support@acme.com
        - Keep responses concise
        
        Products: Widget Pro ($99), Widget Basic ($49), Widget Enterprise (contact sales)`
      },
      {
        role: 'user',
        content: event.preview
      }
    ],
    temperature: 0.5,
    max_tokens: 300
  },
  {
    headers: {
      'Authorization': `Bearer ${env.TENSORX_API_KEY}`,
      'Content-Type': 'application/json'
    }
  }
);

workflow.aiResponse = response.data.choices[0].message.content;
```

### Intent Classifier

Use AI to classify user intent:

```javascript
const response = await axios.post(
  'https://api.tensorx.ai/v1/chat/completions',
  {
    model: 'z-ai/glm-5.1',
    messages: [
      {
        role: 'system',
        content: `Classify the user's intent into one of these categories:
        - pricing: Questions about costs, plans, pricing
        - support: Technical issues, problems, bugs
        - sales: Interest in buying, demos, trials
        - general: Everything else
        
        Respond with only the category name, nothing else.`
      },
      {
        role: 'user',
        content: event.preview
      }
    ],
    temperature: 0.1,
    max_tokens: 20
  },
  {
    headers: {
      'Authorization': `Bearer ${env.TENSORX_API_KEY}`,
      'Content-Type': 'application/json'
    }
  }
);

workflow.userIntent = response.data.choices[0].message.content.trim().toLowerCase();
```

Then use **Expression** transitions to route based on `workflow.userIntent`.

### FAQ Bot with Knowledge Base

```javascript
// Assuming you have FAQ content in a knowledge base variable
const faqContent = `
Q: What are your hours?
A: We're open Monday-Friday, 9am-5pm EST.

Q: How do I reset my password?
A: Click "Forgot Password" on the login page.

Q: What's your refund policy?
A: 30-day money-back guarantee on all products.
`;

const response = await axios.post(
  'https://api.tensorx.ai/v1/chat/completions',
  {
    model: 'z-ai/glm-5.2',
    messages: [
      {
        role: 'system',
        content: `You are a helpful FAQ assistant. Answer based on this knowledge base:

${faqContent}

If the question isn't covered, say "I don't have that information, but you can contact support@company.com"`
      },
      {
        role: 'user',
        content: event.preview
      }
    ],
    temperature: 0.3,
    max_tokens: 200
  },
  {
    headers: {
      'Authorization': `Bearer ${env.TENSORX_API_KEY}`,
      'Content-Type': 'application/json'
    }
  }
);

workflow.aiResponse = response.data.choices[0].message.content;
```

## Recommended Models

{% hint style="info" %}
**For Coding Tasks:**

* `z-ai/glm-5.1` - Best for tool calling and structured outputs
* `minimax/minimax-m2.5` - Best for complex reasoning tasks
  {% endhint %}

| Model ID               | Best For                                 |
| ---------------------- | ---------------------------------------- |
| `z-ai/glm-5.2`         | General conversation                     |
| `z-ai/glm-5.1`         | Intent classification, structured output |
| `minimax/minimax-m2.5` | Complex reasoning                        |
| `moonshotai/kimi-k2.5` | Vision, long context                     |

## Error Handling

Add try-catch for robust error handling:

```javascript
try {
  const response = await axios.post(
    'https://api.tensorx.ai/v1/chat/completions',
    {
      model: 'z-ai/glm-5.2',
      messages: [
        { role: 'user', content: event.preview }
      ],
      temperature: 0.7,
      max_tokens: 500
    },
    {
      headers: {
        'Authorization': `Bearer ${env.TENSORX_API_KEY}`,
        'Content-Type': 'application/json'
      },
      timeout: 30000 // 30 second timeout
    }
  );
  
  workflow.aiResponse = response.data.choices[0].message.content;
  workflow.aiError = null;
  
} catch (error) {
  console.error('TensorX API error:', error.message);
  workflow.aiResponse = "I'm sorry, I'm having trouble processing your request right now.";
  workflow.aiError = error.message;
}
```

## Best Practices

### 1. Use Environment Variables

Never hardcode API keys. Use Botpress secrets:

* `env.TENSORX_API_KEY`

### 2. Set Appropriate Timeouts

AI responses can take a few seconds. Set reasonable timeouts:

```javascript
{ timeout: 30000 } // 30 seconds
```

### 3. Limit Conversation History

For multi-turn conversations, limit history to prevent token overflow:

```javascript
// Keep only last 10 messages
if (workflow.conversationHistory.length > 10) {
  workflow.conversationHistory = workflow.conversationHistory.slice(-10);
}
```

### 4. Handle Edge Cases

* Empty user messages
* Very long messages
* API failures

## Troubleshooting

### "axios is not defined"

Axios is available globally in Botpress Execute Code. If you get this error:

* Check for typos in `axios`
* Ensure you're using `await` for the API call

### API Key Not Working

* Verify the secret variable name matches: `env.TENSORX_API_KEY`
* Check the key at [app.tensorx.ai](https://app.tensorx.ai)
* Ensure there are no extra spaces

### Timeout Errors

* Increase timeout value
* Use a faster model
* Reduce max\_tokens for quicker responses

### Response Not Displaying

* Check the variable name: `workflow.aiResponse`
* Ensure the Text card references `{{workflow.aiResponse}}`
* Debug by logging: `console.log(response.data)`

## Support

Need help? Contact us at <support@tensorx.ai>


# Credit & Billing

Everything you need to know about payments, credits, and billing on TensorX.

***

## How Billing Works

TensorX uses a **prepaid credit system**. You add credits to your account and pay only for what you use based on token consumption.

```
Cost = (Input Tokens × Input Price) + (Output Tokens × Output Price)
```

{% hint style="info" %}
**View Live Pricing**: [tensorx.ai/models](https://tensorx.ai/models) - Pricing displayed per 1M tokens.
{% endhint %}

***

## Payment Methods

We accept multiple payment options to make it easy for developers worldwide:

| Method                | Type        | Supported                |
| --------------------- | ----------- | ------------------------ |
| **Credit/Debit Card** | Traditional | ✅ Visa, Mastercard, Amex |

***

## Adding Credits

To add credits to your account:

1. Log in to [app.tensorx.ai](https://app.tensorx.ai)
2. Navigate to your [dashboard](https://app.tensorx.ai/dashboard)
3. Click **Add Credits**
4. Choose your payment method and amount
5. Complete the payment

Credits are added to your account instantly after successful payment.

{% hint style="warning" %}
**Rate limits:** Depositing credits does not change your rate limit tier. Tiers are based on your **total consumed spend** — the cumulative dollar value of tokens you have actually used — not your credit balance. See [Rate Limits](https://docs.tensorx.ai/api-reference/rate-limits) for tier details and how to request higher limits.
{% endhint %}

***

## Balance Management

### Minimum Balance Requirement

{% hint style="warning" %}
**Important:** When your balance falls below **$0.05**, your account and API keys will be automatically disabled to prevent negative balance.

You must top up your account to re-enable access.
{% endhint %}

### Low Balance Notifications

You'll receive notifications when your balance is running low:

* Email alerts sent automatically at a fixed low-balance threshold
* Dashboard warnings when balance is low

### Re-enabling Your Account

If your account has been disabled due to low balance:

1. Log in to [app.tensorx.ai](https://app.tensorx.ai)
2. Add credits to your account
3. Your API keys will be automatically re-enabled once your balance is above $0.05

***

## Usage & Monitoring

Track your credit usage and API activity in your [dashboard](https://app.tensorx.ai/dashboard):

* 📊 **Usage History** - See all API requests and costs
* 💰 **Credit Balance** - Check remaining credits
* 📈 **Usage Trends** - Monitor your consumption over time
* 🔑 **API Key Usage** - Track usage per API key

***

## Pricing

Pricing is based on token usage. Each model has different rates for input and output tokens.

{% hint style="success" %}
**View Current Pricing**: [tensorx.ai/models](https://tensorx.ai/models)

All pricing is displayed per 1M tokens.
{% endhint %}

### How to Estimate Costs

* **1 token ≈ 4 characters** of English text
* **100 tokens ≈ 75 words**
* A typical API request with a short prompt and response might use 500-2000 tokens

### Cost Optimization Tips

1. **Choose the right model** - Use smaller/faster models for simple tasks
2. **Set max\_tokens** - Limit output length when appropriate
3. **Use system prompts efficiently** - Keep them concise
4. **Cache responses** - Don't repeat identical queries
5. **Monitor usage** - Check your dashboard regularly

***

## Refund Policy

{% hint style="info" %}
**24-hour refund window.** If you need a refund, contact <support@tensorx.ai> within 24 hours of your purchase. After 24 hours, all purchases are final and credits become non-refundable.
{% endhint %}

We recommend starting with a small amount to test the platform before making a larger purchase.

***

## FAQ

### Do credits expire?

No, credits do not expire. Use them whenever you need.

### Can I get an invoice?

Yes, every top-up generates an invoice you can download yourself:

1. Sign in to the [dashboard](https://app.tensorx.ai).
2. Open **Billing** from the sidebar.
3. In the **Recent Transactions** list, click the **Invoice** button next to the deposit you want.

The invoice opens in a new tab with a **Download PDF** option.

### What happens when I run out of credits?

When your balance falls below $0.05, your account and API keys will be disabled. API requests will return authentication errors. Add credits to re-enable your account.

### Is there a minimum purchase?

Check [tensorx.ai](https://tensorx.ai) for current minimum purchase amounts.

### Can I set up auto top-up?

Yes. Auto top-up is self-serve from your [dashboard](https://app.tensorx.ai/dashboard). You set two values:

1. A **trigger balance** — when your credit balance falls to this amount, a top-up is made automatically.
2. A **refill amount** — the amount of credit added each time the trigger is reached.

No support request is needed to switch it on or off.

***

## Need Help?

* 📧 **Email**: <support@tensorx.ai>
* 💬 **Contact Support**: [Contact page](/support/support)


# API Keys

Create, manage, and secure your API keys.

***

## Creating an API Key

1. Go to [Dashboard → API Keys](https://app.tensorx.ai/dashboard/keys)
2. Click **Generate New Key**
3. Enter a descriptive name (3-50 characters)
4. Click **Create**

{% hint style="warning" %}
**Important:** Your API key is only shown once at creation. Copy it immediately and store it securely.
{% endhint %}

### Key Format

Your API key looks like this:

```
sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

In your dashboard, keys are displayed as: `sk-a1b2...wxyz` (first 8 + last 4 characters)

***

## Naming Your Keys

Use descriptive names to track usage and organize your keys:

| Good Names          | Purpose          |
| ------------------- | ---------------- |
| `Production API`    | Live application |
| `Development`       | Local testing    |
| `CI/CD Pipeline`    | Automated builds |
| `Mobile App v2`     | Specific project |
| `Analytics Service` | Internal tool    |

{% hint style="info" %}
Key names appear in your usage logs, making it easy to track which key generated which costs.
{% endhint %}

***

## Managing Keys

### Enable / Disable

You can temporarily disable a key without deleting it:

1. Go to **API Keys** in your dashboard
2. Click the toggle next to the key
3. Disabled keys reject all API requests immediately

This is useful for:

* Pausing a project temporarily
* Testing what happens when a key is invalid
* Security incidents (disable first, investigate later)

### Regenerate

If you suspect a key has been compromised:

1. Click **Regenerate** next to the key
2. Confirm the action
3. Copy the new key immediately

{% hint style="warning" %}
The old key stops working instantly. Update your applications before regenerating.
{% endhint %}

### Delete

Deleting a key is permanent:

* The key stops working immediately
* Usage history is preserved for your records
* This action cannot be undone

***

## Per-Key Usage Tracking

Every API request is logged with the key that made it. View usage by key in your dashboard:

* **Total cost** per key
* **Request count**
* **Tokens used** (input/output)
* **Last used** timestamp
* **Models accessed**

This helps you:

* Track costs per project or environment
* Identify unused keys to clean up
* Spot unexpected usage patterns

***

## Rate Limits

| Limit                              | Value                |
| ---------------------------------- | -------------------- |
| Key operations (create/regenerate) | 15 per hour          |
| API requests                       | 60 per minute        |
| Tokens                             | 2,000,000 per minute |

These limits apply **per API key**. Each key has its own independent rate limit.

***

## Security Best Practices

### Do ✅

* **Use environment variables** - Never hardcode keys in source code
* **Different keys per environment** - Separate dev, staging, and production
* **Name keys descriptively** - Makes auditing easier
* **Rotate regularly** - Use the regenerate feature periodically
* **Delete unused keys** - Reduce your attack surface
* **Monitor usage** - Check logs for unexpected activity

### Don't ❌

* **Never commit keys to git** - Use `.env` files (add to `.gitignore`)
* **Never share keys publicly** - Treat them like passwords
* **Never expose in client-side code** - Keys belong on the server only

### Environment Variables Example

```bash
# .env file (add to .gitignore!)
TENSORX_API_KEY=sk-your-key-here
```

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["TENSORX_API_KEY"],
    base_url="https://api.tensorx.ai/v1"
)
```

***

## Team API Keys

When you're part of a team:

* Team owners and admins can create keys for the team
* All team members can use team API keys
* Usage is billed to the team balance
* Your personal keys are archived while on a team

See [Team Account](/account/team) for more details.

***

## Troubleshooting

### "Invalid API Key"

* Verify you copied the complete key (including `sk-` prefix)
* Check the key isn't disabled in your dashboard
* Confirm you're using the correct base URL: `https://api.tensorx.ai/v1`

### "Insufficient Balance"

* Keys require a wallet balance > $0 to create
* Keys are auto-disabled when balance drops to $0.05
* Add funds to re-enable your keys

### Lost Your Key?

API keys cannot be recovered once lost. You'll need to:

1. Delete the old key (if you remember which one)
2. Create a new key
3. Update your applications with the new key

***

## Need Help?

* 📧 **Email**: <support@tensorx.ai>


# Team Account

Collaborate with your team using shared resources and credits on TensorX.

***

## Overview

TensorX provides team accounts to facilitate collaboration among multiple users. Team accounts allow you to:

* **Share credits** - Pool resources across your team
* **Manage API keys** - Create and manage keys for team members
* **Track usage** - Monitor usage across the entire team
* **Control access** - Assign roles and permissions

{% hint style="info" %}
Each user can create one team account but can join multiple teams created by others.
{% endhint %}

***

## Creating a Team

To create a team:

1. Log in to [app.tensorx.ai](https://app.tensorx.ai)
2. Navigate to your dashboard
3. Click **Create Team**
4. Provide a team name (maximum 48 characters)

When you create a team, your paid balance (deposits made via Stripe or crypto) transfers to the team account.

{% hint style="warning" %}
This is a **one-way transfer**. To recover team funds, you must delete the team.
{% endhint %}

***

## Inviting Team Members

Team owners and admins can invite new members by email:

1. Go to your Team Management page
2. Enter the email address of the person you want to invite
3. Click **Send Invite**
4. The invited user receives an email with a link to join

### Joining a Team

When you receive a team invitation:

1. Click the link in the invitation email
2. Log in or create a TensorX account if needed
3. Accept the invitation to join the team

When you join a team:

* Your **paid deposits** (Stripe, crypto) transfer to the team wallet
* Your personal API keys are temporarily archived
* You'll use team API keys while part of the team

### Leaving a Team

Any team member can leave at any time from Team Management. The team owner cannot leave their own team.

When you leave a team:

* Your personal API keys are restored
* Any paid deposits you transferred stay with the team
* Any team API keys you created are deleted

***

## Team Roles

| Role       | Permissions                                        |
| ---------- | -------------------------------------------------- |
| **Owner**  | Full access, billing, team management, delete team |
| **Admin**  | Manage members (invite/remove), view usage         |
| **Member** | Use team API keys, view own usage                  |

{% hint style="info" %}
Admins can help manage the team but do not have access to billing or team deletion.
{% endhint %}

***

## Team Billing

### Shared Credits

* Teams have a shared credit pool
* All team API usage draws from the team balance
* The team owner manages billing and top-ups

{% hint style="warning" %}
When the team balance drops to $0.05 or below, team API keys are temporarily suspended. The owner will see a warning to add funds.
{% endhint %}

### How Funds Transfer

When creating or joining a team:

* **Paid deposits** (Stripe, crypto) transfer to the team
* Transfers are processed instantly

{% hint style="info" %}
Fund transfers to a team are one-way. The only way to recover team funds is when the owner deletes the team.
{% endhint %}

### Usage Tracking

Track team usage in the dashboard:

* **By team member** - See each member's API usage
* **By API key** - View 30-day stats per key including calls, spend, and tokens
* **Personal usage** - Members can see their own usage contribution

***

## API Keys

### Team API Keys

* Team owners and admins can create API keys for the team
* All team members can use team API keys
* Usage is billed to the team balance

### Personal API Keys

* When you join a team, your personal API keys are archived (not deleted)
* When you leave a team, your personal API keys are automatically restored
* This ensures a smooth transition in and out of teams

***

## Team Deletion

Only the team owner can delete a team. When a team is deleted:

1. All team members are automatically removed
2. Members' personal API keys are restored
3. Remaining team balance transfers to the owner's personal account

***

## Best Practices

1. **Use separate API keys** - Create unique API keys for different projects or team members
2. **Monitor usage** - Check your dashboard regularly to track team spending
3. **Assign admin roles** - Let trusted members help manage invitations without giving billing access

***

## Coming Soon

We're working on additional team features:

* 📊 **Usage quotas** - Set limits per member or API key
* 🔔 **Advanced notifications** - Customizable alerts

***

## Need Help?

* 📧 **Email**: <support@tensorx.ai>
* 💬 **Contact Support**: [Contact page](/support/support)


# Troubleshooting

Common issues and solutions when using TensorX with AI coding tools.

***

## API Error: Cannot read properties of undefined

### Cause

Usually happens when environment variables are conflicting or the base URL is incorrect.

### Solution

1. **Verify your API base URL**:
   * For Claude Code: `https://api.tensorx.ai`
   * For Cursor/Cline: `https://api.tensorx.ai/v1`
2. **Replace the placeholder** `YOUR_API_KEY` with your actual TensorX API key
3. **Clear conflicting environment variables**:

```bash
# For Claude Code
unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL

# For Cursor/Cline
unset OPENAI_API_KEY OPENAI_BASE_URL
```

4. **Check your API credits** at [app.tensorx.ai/dashboard](https://app.tensorx.ai/dashboard)

***

## Claude Code: Model Errors or Background Task Failures

### Cause

Claude Code requires **all 5 model environment variables** to be set, even if you only use one model. Missing variables cause background task failures.

### Solution

Set all required model variables:

```bash
export ANTHROPIC_MODEL="z-ai/glm-5.1"
export ANTHROPIC_SMALL_FAST_MODEL="z-ai/glm-5.1"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="z-ai/glm-5.1"
export ANTHROPIC_DEFAULT_SONNET_MODEL="z-ai/glm-5.1"
export ANTHROPIC_DEFAULT_OPUS_MODEL="z-ai/glm-5.1"
```

{% hint style="warning" %}
**All 5 variables are required.** Claude Code uses different model variables for different internal tasks. If any are missing, you'll see errors.
{% endhint %}

***

## Connection Timeout

### Cause

The default timeout may be too short for complex operations.

### Solution

Increase the timeout value in your configuration:

```bash
export API_TIMEOUT_MS="3000000"
```

***

## Model Not Found

### Cause

Using incorrect model ID format.

### Solution

Always use the full model ID with provider prefix:

| ✅ Correct              | ❌ Incorrect  |
| ---------------------- | ------------ |
| `z-ai/glm-5.1`         | `glm-5.1`    |
| `minimax/minimax-m2`   | `minimax-m2` |
| `minimax/minimax-m2.5` | `m2.5`       |

Browse all available models at [tensorx.ai/models](https://tensorx.ai/models).

***

## Authentication Failed

### Cause

Invalid or expired API key.

### Solution

1. Log in to [app.tensorx.ai](https://app.tensorx.ai)
2. Navigate to your [dashboard](https://app.tensorx.ai/dashboard)
3. Generate a new API key
4. Update your configuration with the new key

***

## OAuth Conflict (Claude Code)

### Cause

Claude Code's built-in OAuth login conflicts with TensorX configuration.

### Solution

If you accidentally trigger OAuth:

1. Press `Ctrl+C` to cancel the OAuth prompt
2. Verify your environment variables are set correctly
3. Restart Claude Code

{% hint style="info" %}
**Print mode (`-p`)** works without any Anthropic account or OAuth - it's the fastest way to test your setup.
{% endhint %}

***

## Rate Limiting

### Cause

Too many requests in a short period, or too many tokens reserved in a single request.

### Diagnosing RPM vs TPM Limits

Check the `Limit type` field in the 429 error message to determine which limit you hit:

| Error message          | You hit | Meaning                             |
| ---------------------- | ------- | ----------------------------------- |
| `Limit type: requests` | RPM     | Too many API calls per minute       |
| `Limit type: tokens`   | TPM     | Too many tokens reserved per minute |

### Solution

* **If you hit RPM:** Wait a few seconds between requests, or batch similar calls together
* **If you hit TPM:** Your `max_tokens` value may be too high — each request reserves its full `max_tokens` against your TPM allowance while in flight

{% hint style="warning" %}
Some editors and IDEs (e.g. Zed) default `max_tokens` to the full context window size (1,048,576). This means each request reserves \~1M tokens, even if the actual output is only a few thousand. If you're hitting TPM limits after just a few requests, reduce `max_tokens` to a realistic value (e.g. 8192).
{% endhint %}

* Check your usage at [app.tensorx.ai/dashboard](https://app.tensorx.ai/dashboard)
* See [Rate Limits](https://docs.tensorx.ai/api-reference/rate-limits) for tier details and how to request higher limits
* Contact <support@tensorx.ai> if you need higher limits

***

## Need More Help?

* 📧 **Email**: <support@tensorx.ai>
* 📚 **Documentation**: [docs.tensorx.ai](https://docs.tensorx.ai)
* 💬 **Contact Support**: [Contact page](/support/support)


# Contact Support

We're here to help! Reach out through any of the channels below.

## 📧 Email

[**support@tensorx.ai**](mailto:support@tensorx.ai)

Our team typically responds within 24 hours.

***

## 🚀 Coming Soon

We're adding more ways to reach us:

| Channel          | Status      |
| ---------------- | ----------- |
| 💬 **Live Chat** | Coming Soon |
| 📱 **WhatsApp**  | Coming Soon |
| ✈️ **Telegram**  | Coming Soon |
| 🎮 **Discord**   | Coming Soon |

***

## 🔗 Quick Links

* 🌐 **Website:** [tensorx.ai](https://tensorx.ai)
* 📖 **Documentation:** You're here!
* ❓ **Troubleshooting:** [Common issues](/support/troubleshooting)


# AI Coding Tools Integration

Use Tensorix-hosted models with popular AI coding tools. Get powerful code understanding, multi-turn dialogue, and reasoning capabilities.

## Recommended Models for Claude Code

We recommend the following models for use with Claude Code:

| Model                    | Model ID               | Why Use It                                                                                             |
| ------------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------ |
| **GLM-4.7**              | `z-ai/glm-4.7`         | Best tool calling & function support ([docs](https://docs.z.ai/scenario-example/develop-tools/claude)) |
| **MiniMax-M2** (Default) | `minimax/minimax-m2`   | Excellent reasoning, 197K context                                                                      |
| **MiniMax-M2.1**         | `minimax/minimax-m2.1` | Latest MiniMax with improved capabilities                                                              |

## Prerequisites

* A [Tensorix account](https://tensorix.ai) with API credits
* Your Tensorix API key (from your dashboard)

## All Available Models

| Model        | Model ID               | Context | Best For                |
| ------------ | ---------------------- | ------- | ----------------------- |
| GLM-4.7      | `z-ai/glm-4.7`         | 203K    | Tool Use, Functions     |
| MiniMax-M2   | `minimax/minimax-m2`   | 197K    | Reasoning, Long Context |
| MiniMax-M2.1 | `minimax/minimax-m2.1` | 197K    | Latest MiniMax          |
| GLM-4.6      | `z-ai/glm-4.6`         | 203K    | Reasoning Tasks         |

## API Endpoints

| Type                 | Base URL                            |
| -------------------- | ----------------------------------- |
| OpenAI Compatible    | `https://api.tensorix.ai/v1`        |
| Anthropic Compatible | `https://api.tensorix.ai/anthropic` |


# Claude Code CLI

The recommended way to use Tensorix models with Claude Code.

## Recommended Models

We recommend these models for Claude Code:

| Model                    | Model ID               | Best For                                                                                            |
| ------------------------ | ---------------------- | --------------------------------------------------------------------------------------------------- |
| **GLM-4.7**              | `z-ai/glm-4.7`         | Tool calling & functions ([official docs](https://docs.z.ai/scenario-example/develop-tools/claude)) |
| **MiniMax-M2** (Default) | `minimax/minimax-m2`   | General coding, reasoning                                                                           |
| **MiniMax-M2.1**         | `minimax/minimax-m2.1` | Latest capabilities                                                                                 |

## Install Claude Code

Refer to the [Claude Code documentation](https://docs.anthropic.com/claude-code) for installation.

## Configure Tensorix API

{% hint style="warning" %}
**Important:** Clear existing Anthropic environment variables before configuration to avoid conflicts:

* `ANTHROPIC_AUTH_TOKEN`
* `ANTHROPIC_BASE_URL`
  {% endhint %}

1. Edit or create the Claude Code configuration file at `~/.claude/settings.json`:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_SMALL_FAST_MODEL": "minimax/minimax-m2",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

2. Navigate to your working directory and run `claude` in the terminal.
3. Select **Trust This Folder** when prompted.
4. Start coding with Tensorix!

## Using Different Models

Update `ANTHROPIC_MODEL` to switch models.

### MiniMax-M2 (Default)

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_SMALL_FAST_MODEL": "minimax/minimax-m2",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

### MiniMax-M2.1

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "minimax/minimax-m2.1",
    "ANTHROPIC_SMALL_FAST_MODEL": "minimax/minimax-m2.1",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

### GLM-4.7

Best for tool calling and function support. See [official GLM Claude Code docs](https://docs.z.ai/scenario-example/develop-tools/claude).

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "z-ai/glm-4.7",
    "ANTHROPIC_SMALL_FAST_MODEL": "z-ai/glm-4.7",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```


# Claude Code VS Code

Use Tensorix models directly in VS Code with the Claude Code extension.

## Installation

1. Install the **Claude Code Extension** from VS Code marketplace
2. Click **Settings** after installation

## Configuration

### Set the Model

In VS Code Settings → `Claude Code: Selected Model`, enter:

```
minimax/minimax-m2
```

### Configure Environment Variables

Add these to your VS Code `settings.json`:

```json
{
  "claudeCode.environmentVariables": [
    {
      "name": "ANTHROPIC_BASE_URL",
      "value": "https://api.tensorix.ai/anthropic"
    },
    {
      "name": "ANTHROPIC_AUTH_TOKEN",
      "value": "<YOUR_TENSORIX_API_KEY>"
    },
    {
      "name": "API_TIMEOUT_MS",
      "value": "3000000"
    },
    {
      "name": "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
      "value": "1"
    },
    {
      "name": "ANTHROPIC_MODEL",
      "value": "minimax/minimax-m2"
    },
    {
      "name": "ANTHROPIC_SMALL_FAST_MODEL",
      "value": "minimax/minimax-m2"
    },
    {
      "name": "ANTHROPIC_DEFAULT_SONNET_MODEL",
      "value": "minimax/minimax-m2"
    },
    {
      "name": "ANTHROPIC_DEFAULT_OPUS_MODEL",
      "value": "minimax/minimax-m2"
    },
    {
      "name": "ANTHROPIC_DEFAULT_HAIKU_MODEL",
      "value": "minimax/minimax-m2"
    }
  ]
}
```

## Switching Models

To use a different model, update all `ANTHROPIC_*_MODEL` values:

| Model                | Value                  |
| -------------------- | ---------------------- |
| GLM-4.7              | `z-ai/glm-4.7`         |
| MiniMax-M2 (Default) | `minimax/minimax-m2`   |
| MiniMax-M2.1         | `minimax/minimax-m2.1` |


# Cursor

Use Tensorix models with [Cursor](https://cursor.sh), the AI-powered code editor.

## Installation

Download and install [Cursor](https://cursor.sh).

## Configuration

{% hint style="warning" %}
**Important:** Clear existing OpenAI environment variables before configuration
{% endhint %}

### Step 1: Configure API Settings

1. Open Cursor **Settings** → **Models**
2. Expand **API Keys** section
3. Enable **Override OpenAI Base URL**
4. Enter Base URL: `https://api.tensorix.ai/v1`
5. Enter your Tensorix API key in the **OpenAI API Key** field
6. Click the verification button to test the connection

### Step 2: Add Custom Model

1. In **Models** section, click **Add Custom Model**
2. Enter model name: `minimax/minimax-m2`
3. Click **Add**
4. Enable the model
5. Select it in the chat panel

## Available Models

| Model        | ID                     | Best For                |
| ------------ | ---------------------- | ----------------------- |
| GLM-4.7      | `z-ai/glm-4.7`         | Tool Use, Functions     |
| MiniMax-M2   | `minimax/minimax-m2`   | Reasoning, Long Context |
| MiniMax-M2.1 | `minimax/minimax-m2.1` | Latest Capabilities     |


# Cline

Use Tensorix models with [Cline](https://github.com/cline/cline), the autonomous coding agent for VS Code.

## Installation

1. Open VS Code Extensions
2. Search for **"Cline"**
3. Click **Install**
4. Restart VS Code

## Configuration

1. Click **Use your own API key** in Cline
2. Under **API Provider**, select **OpenAI Compatible**
3. Configure the following:

| Setting  | Value                        |
| -------- | ---------------------------- |
| Base URL | `https://api.tensorix.ai/v1` |
| API Key  | Your Tensorix API key        |
| Model    | `minimax/minimax-m2`         |

4. Click **Let's go!** and then **Done**

## Available Models

| Model        | ID                     | Best For                |
| ------------ | ---------------------- | ----------------------- |
| GLM-4.7      | `z-ai/glm-4.7`         | Tool Use, Functions     |
| MiniMax-M2   | `minimax/minimax-m2`   | Reasoning, Long Context |
| MiniMax-M2.1 | `minimax/minimax-m2.1` | Latest Capabilities     |

## Tips

* Cline works best with models that have strong reasoning capabilities
* MiniMax-M2/M2.1 is recommended for complex multi-file operations
* Use GLM-4.7 when you need function/tool calling


# Troubleshooting

Common issues and solutions when using Tensorix with AI coding tools.

## API Error: Cannot read properties of undefined

### Cause

Usually happens when environment variables are conflicting or the base URL is incorrect.

### Solution

1. **Verify your API base URL**:
   * For Claude Code: `https://api.tensorix.ai/anthropic`
   * For Cursor/Cline: `https://api.tensorix.ai/v1`
2. **Replace the placeholder** `<YOUR_TENSORIX_API_KEY>` with your actual API key
3. **Clear conflicting environment variables**:

```bash
# For Claude Code
unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL

# For Cursor/Cline
unset OPENAI_API_KEY OPENAI_BASE_URL
```

4. **Check your API credits** at [tensorix.ai](https://tensorix.ai)

## Connection Timeout

### Cause

The default timeout may be too short for complex operations.

### Solution

Increase the timeout value in your configuration:

```json
"API_TIMEOUT_MS": "3000000"
```

## Model Not Found

### Cause

Using incorrect model ID format.

### Solution

Always use the full model ID with provider prefix:

| ✅ Correct              | ❌ Incorrect  |
| ---------------------- | ------------ |
| `z-ai/glm-4.7`         | `glm-4.7`    |
| `minimax/minimax-m2`   | `minimax-m2` |
| `minimax/minimax-m2.1` | `m2.1`       |

## Authentication Failed

### Cause

Invalid or expired API key.

### Solution

1. Log in to [tensorix.ai](https://tensorix.ai)
2. Navigate to your dashboard
3. Generate a new API key
4. Update your configuration with the new key

## Rate Limiting

### Cause

Too many requests in a short period.

### Solution

* Wait a few seconds between requests
* Consider upgrading your plan for higher rate limits
* Use batch operations when possible

## Need More Help?

* **Email**: <support@tensorix.ai>
* **Documentation**: [docs.tensorix.ai](https://docs.tensorix.ai)


# Developer Platform API

Learn more about documenting APIs in GitBook.

GitBook automatically generates pages and endpoints for your OpenAPI spec. Fully customizable and equipped with testing capabilities, your documentation has never been more powerful.

The API reference below is automatically generated from a demo OpenAPI spec in this space.

<a href="https://gitbookio.github.io/onboarding-template-images/gitbook-petstore.yaml" class="button primary" data-icon="arrow-up-right-from-square">View OpenAPI spec</a>


# Welcome to the GitBook Petstore API

This GitBook API documentation template serves as a starting point for creating clear, interactive, and user-friendly API documentation.

Use this template to explore best practices in structuring your docs, showcasing endpoints, and guiding users through your API. Everything here can be adapted to fit your own product.

#### How this demo works

This reference is automatically generated from an OpenAPI spec uploaded to this GitBook space. GitBook reads the spec and creates a page for each tag, with interactive endpoint blocks for every operation — no manual authoring required.

A few things worth noticing as you explore:

* **Page groups** — tags with no endpoints (like *Store* and *Pets*) become navigation sections automatically, keeping related endpoints grouped without any extra configuration.
* **Auto-split pages** — `##` headings inside `info.description` are automatically split into separate pages in the navigation, which is how this welcome section is structured.
* **Stability badges** — some endpoints are marked `experimental` or `beta` using the `x-stability` extension. You'll see these highlighted on the endpoint itself.
* **Deprecation warnings** — `GET /pets/{petId}` is marked deprecated with a sunset date, surfaced as a warning banner on that endpoint's page.
* **Code samples** — each endpoint includes hand-written examples in cURL, JavaScript, and Python via `x-codeSamples`, supplementing the auto-generated snippets.
* **Try it panel** — most endpoints have a live testing panel on the right. `GET /store/orders` has it disabled via `x-hideTryItPanel` to show that control is per-endpoint.

To use this template for your own API, replace the spec with your own OpenAPI file and adjust the `info.description` to match your product.


# Servers & Authentication

#### Servers

{% tabs %}
{% tab title="Production" %}
**Base URL** `https://petstore.example.com/v1`
{% endtab %}

{% tab title="Staging" %}
**Base URL** `https://staging.petstore.example.com/v1`
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Both servers are available in the **Try it** panel on each endpoint page. Use the server switcher in the top-right of the panel to toggle between Production and Staging without leaving the docs.
{% endhint %}

#### Authentication

All requests must include your API key in the `Authorization` header:

```
Authorization: Bearer YOUR_API_KEY
```

{% hint style="info" %}
Generate an API key from your [account dashboard](https://petstore.example.com/dashboard/keys). Keys are scoped to a single workspace.
{% endhint %}


# Getting started

{% stepper %}
{% step %}

### Create an account

Sign up at [petstore.example.com](https://petstore.example.com) — it's free.
{% endstep %}

{% step %}

### Get your API key

Head to your dashboard and copy your key from the **API Keys** section.
{% endstep %}

{% step %}

### Make your first request

Call `GET /pets` to verify connectivity and see available pets.
{% endstep %}
{% endstepper %}


# Error responses

All errors follow a consistent structure:

```json
{
  "error": {
    "code": "not_found",
    "message": "The requested resource could not be found.",
    "status": 404
  }
}
```

| Status | Meaning                                   |
| ------ | ----------------------------------------- |
| `400`  | Bad request — check your request body     |
| `401`  | Unauthorized — missing or invalid API key |
| `403`  | Forbidden — insufficient permissions      |
| `404`  | Not found                                 |
| `429`  | Rate limited — back off and retry         |
| `500`  | Server error                              |

{% hint style="warning" %}
This API is for demo purposes only — **don't** use it in production.
{% endhint %}


# Store


# Orders

Place and manage customer orders.

## List orders

> Returns all orders placed in the store. Does not currently support filtering or pagination.\
> \
> {% hint style="info" %}\
> Filtering and pagination are planned for v2. Subscribe to the \[changelog]\(<https://petstore.example.com/changelog>) for updates.\
> {% endhint %}<br>

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"orders"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"Order":{"type":"object","properties":{"id":{"type":"integer","format":"int64","description":"Unique order identifier."},"petId":{"type":"integer","format":"int64","description":"The ID of the animal in this order."},"quantity":{"type":"integer","description":"Number of units ordered."},"shipDate":{"type":"string","format":"date-time","description":"Expected or actual ship date in ISO 8601 format."},"complete":{"type":"boolean","description":"Whether the order has been fulfilled."}}},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/store/orders":{"get":{"summary":"List orders","description":"Returns all orders placed in the store. Does not currently support filtering or pagination.\n\n{% hint style=\"info\" %}\nFiltering and pagination are planned for v2. Subscribe to the [changelog](https://petstore.example.com/changelog) for updates.\n{% endhint %}\n","tags":["orders"],"operationId":"listOrders","responses":{"200":{"description":"An array of orders.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}}}}
```

## Cancel an order

> Cancels an order by ID. Only orders with a status of \`pending\` can be cancelled — orders that have already shipped cannot be reversed.

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"orders"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"responses":{"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"The requested resource could not be found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}}},"paths":{"/store/orders/{orderId}":{"delete":{"summary":"Cancel an order","description":"Cancels an order by ID. Only orders with a status of `pending` can be cancelled — orders that have already shipped cannot be reversed.","tags":["orders"],"operationId":"cancelOrder","parameters":[{"name":"orderId","in":"path","required":true,"description":"The ID of the order to cancel.","schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"Order cancelled successfully."},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"Order cannot be cancelled — it has already shipped."}}}}}}
```


# Inventory

Track and update stock levels for pets in the store.

## List inventory

> Returns current stock levels for all pets in the store.

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"inventory"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"InventoryItem":{"type":"object","required":["petId","quantity","status"],"properties":{"petId":{"type":"integer","format":"int64","description":"The ID of the animal this entry tracks."},"quantity":{"type":"integer","description":"Current stock count."},"status":{"$ref":"#/components/schemas/PetStatus"}}},"PetStatus":{"type":"string","enum":["available","pending","sold"]},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/inventory":{"get":{"summary":"List inventory","description":"Returns current stock levels for all pets in the store.","tags":["inventory"],"operationId":"listInventory","responses":{"200":{"description":"An array of inventory entries.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/InventoryItem"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}}}}
```

## Update stock level

> Updates the stock quantity for a specific pet. Use this to record new arrivals, returns, or manual adjustments.\
> \
> {% hint style="warning" %}\
> This endpoint is \*\*experimental\*\* — the request shape may change before it reaches stable.\
> {% endhint %}<br>

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"inventory"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"InventoryUpdate":{"type":"object","required":["quantity"],"properties":{"quantity":{"type":"integer","description":"The new stock count."}}},"InventoryItem":{"type":"object","required":["petId","quantity","status"],"properties":{"petId":{"type":"integer","format":"int64","description":"The ID of the animal this entry tracks."},"quantity":{"type":"integer","description":"Current stock count."},"status":{"$ref":"#/components/schemas/PetStatus"}}},"PetStatus":{"type":"string","enum":["available","pending","sold"]},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"BadRequest":{"description":"The request body is missing required fields or contains invalid values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"The requested resource could not be found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/inventory/{petId}":{"patch":{"summary":"Update stock level","description":"Updates the stock quantity for a specific pet. Use this to record new arrivals, returns, or manual adjustments.\n\n{% hint style=\"warning\" %}\nThis endpoint is **experimental** — the request shape may change before it reaches stable.\n{% endhint %}\n","tags":["inventory"],"operationId":"updateInventory","parameters":[{"name":"petId","in":"path","required":true,"description":"The ID of the pet to update stock for.","schema":{"type":"integer","format":"int64"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryUpdate"}}}},"responses":{"200":{"description":"Updated inventory entry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InventoryItem"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
```


# Pets


# Animals

Browse and manage individual animals available for adoption.

## List all animals

> Returns a paginated list of all animals in the store. Use \`limit\` to control page size and \`status\` to filter by availability.

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"animals"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"PetStatus":{"type":"string","enum":["available","pending","sold"]},"Pets":{"type":"array","items":{"$ref":"#/components/schemas/Pet"}},"Pet":{"allOf":[{"$ref":"#/components/schemas/NewPet"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer","format":"int64","description":"Unique identifier assigned on creation."}}}]},"NewPet":{"type":"object","required":["name","categoryId"],"properties":{"name":{"type":"string","description":"The animal's name."},"categoryId":{"type":"integer","format":"int64","description":"The ID of the category this animal belongs to."},"status":{"$ref":"#/components/schemas/PetStatus"}}},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/pets":{"get":{"summary":"List all animals","description":"Returns a paginated list of all animals in the store. Use `limit` to control page size and `status` to filter by availability.","tags":["animals"],"operationId":"listPets","parameters":[{"name":"limit","in":"query","description":"Maximum number of animals to return. Defaults to 20, max 100.","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"status","in":"query","description":"Filter by availability status.","schema":{"$ref":"#/components/schemas/PetStatus"}}],"responses":{"200":{"description":"A paginated list of animals.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pets"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}}}}
```

## Add an animal

> Adds a new animal to the store. The \`name\` and \`categoryId\` fields are required.

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"animals"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"NewPet":{"type":"object","required":["name","categoryId"],"properties":{"name":{"type":"string","description":"The animal's name."},"categoryId":{"type":"integer","format":"int64","description":"The ID of the category this animal belongs to."},"status":{"$ref":"#/components/schemas/PetStatus"}}},"PetStatus":{"type":"string","enum":["available","pending","sold"]},"Pet":{"allOf":[{"$ref":"#/components/schemas/NewPet"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer","format":"int64","description":"Unique identifier assigned on creation."}}}]},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"BadRequest":{"description":"The request body is missing required fields or contains invalid values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/pets":{"post":{"summary":"Add an animal","description":"Adds a new animal to the store. The `name` and `categoryId` fields are required.","tags":["animals"],"operationId":"createPet","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewPet"}}}},"responses":{"201":{"description":"Animal added successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pet"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}}}}
```

## Get an animal

> Returns details for a single animal by ID.\
> \
> {% hint style="danger" %}\
> \*\*This endpoint is deprecated\*\* and will be removed on \*\*5 December 2030\*\*. Use \`GET /pets\` with a \`status\` filter instead.\
> {% endhint %}<br>

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"animals"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"Pet":{"allOf":[{"$ref":"#/components/schemas/NewPet"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer","format":"int64","description":"Unique identifier assigned on creation."}}}]},"NewPet":{"type":"object","required":["name","categoryId"],"properties":{"name":{"type":"string","description":"The animal's name."},"categoryId":{"type":"integer","format":"int64","description":"The ID of the category this animal belongs to."},"status":{"$ref":"#/components/schemas/PetStatus"}}},"PetStatus":{"type":"string","enum":["available","pending","sold"]},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"The requested resource could not be found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/pets/{petId}":{"get":{"summary":"Get an animal","description":"Returns details for a single animal by ID.\n\n{% hint style=\"danger\" %}\n**This endpoint is deprecated** and will be removed on **5 December 2030**. Use `GET /pets` with a `status` filter instead.\n{% endhint %}\n","tags":["animals"],"operationId":"getPet","parameters":[{"name":"petId","in":"path","required":true,"description":"The ID of the animal to retrieve.","schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"The requested animal.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pet"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}},"deprecated":true}}}}
```


# Categories

Manage the species and breed categories used to classify pets.

## List categories

> Returns all categories available for classifying pets (e.g. dog, cat, rabbit).

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"categories"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"Category":{"allOf":[{"$ref":"#/components/schemas/NewCategory"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer","format":"int64","description":"Unique identifier assigned on creation."}}}]},"NewCategory":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"The category name (e.g. Dog, Cat, Rabbit)."},"description":{"type":"string","description":"A short description of the category."}}},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/categories":{"get":{"summary":"List categories","description":"Returns all categories available for classifying pets (e.g. dog, cat, rabbit).","tags":["categories"],"operationId":"listCategories","responses":{"200":{"description":"An array of categories.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Category"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}}}}
```

## Create a category

> Adds a new category for classifying pets.

```json
{"openapi":"3.0.3","info":{"title":"GitBook Petstore API","version":"1.0.0"},"tags":[{"name":"categories"}],"servers":[{"url":"https://petstore.example.com/v1","description":"Production"},{"url":"https://staging.petstore.example.com/v1","description":"Staging"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a Bearer token in the `Authorization` header."}},"schemas":{"NewCategory":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"The category name (e.g. Dog, Cat, Rabbit)."},"description":{"type":"string","description":"A short description of the category."}}},"Category":{"allOf":[{"$ref":"#/components/schemas/NewCategory"},{"type":"object","required":["id"],"properties":{"id":{"type":"integer","format":"int64","description":"Unique identifier assigned on creation."}}}]},"Error":{"type":"object","required":["code","message","status"],"properties":{"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable description of the error."},"status":{"type":"integer","description":"The HTTP status code."}}}},"responses":{"BadRequest":{"description":"The request body is missing required fields or contains invalid values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/categories":{"post":{"summary":"Create a category","description":"Adds a new category for classifying pets.","tags":["categories"],"operationId":"createCategory","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewCategory"}}}},"responses":{"201":{"description":"Category created successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}}}}
```


# Changelog

New updates and improvements

{% updates format="full" %}
{% update date="2025-12-03" %}

## Product update

See what’s new and improved in our latest update.

### Product feature

* Feature description
* Feature description

<a href="https://gitbook.com/" class="button primary">Read the documentation</a>

<div align="left"><figure><img src="https://gitbookio.github.io/onboarding-template-images/placeholder.png" alt=""><figcaption></figcaption></figure></div>

<details>

<summary>Improved</summary>

* Product improvement
* Product improvement
* Product improvement
* Product improvement
* Product improvement

</details>

<details>

<summary>Fixed</summary>

* Product fix
* Product fix
* Product fix
* Product fix
* Product fix

</details>
{% endupdate %}

{% update date="2025-11-28" %}

## Product update

See what’s new and improved in our latest update.

### Product feature #1

* Feature description
* Feature description

<a href="https://gitbook.com/" class="button primary">Read the documentation</a>

### Product feature #2

* Feature description
* Feature description
* Feature description

<a href="https://gitbook.com/" class="button primary">Read the documentation</a>

<details>

<summary>Improved</summary>

* Product improvement
* Product improvement
* Product improvement
* Product improvement
* Product improvement

</details>

<details>

<summary>Fixed</summary>

* Product fix
* Product fix
* Product fix
* Product fix
* Product fix

</details>
{% endupdate %}
{% endupdates %}


# Help Center

<h2 align="center">What can we help you find?</h2>

<p align="center">Browse the topics below or use the GitBook assistant to ask anything you need help with.</p>

<p align="center"><a href="https://gitbook.com/" class="button primary">Ask GitBook AI</a> <a href="https://gitbook.com/" class="button secondary">Contact support</a></p>

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h4><i class="fa-leaf">:leaf:</i></h4></td><td><strong>Getting started</strong></td><td>Get help with the basics</td><td><a href="https://www.gitbook.com/">https://www.gitbook.com/</a></td></tr><tr><td><h4><i class="fa-plug">:plug:</i></h4></td><td><strong>Integrations</strong></td><td>Extend your workflow</td><td><a href="https://www.gitbook.com/">https://www.gitbook.com/</a></td></tr><tr><td><h4><i class="fa-money-bill-wave">:money-bill-wave:</i></h4></td><td><strong>Plans and billing</strong></td><td>Get help with your billing</td><td><a href="https://www.gitbook.com/">https://www.gitbook.com/</a></td></tr><tr><td><h4><i class="fa-heart">:heart:</i></h4></td><td><strong>Community</strong></td><td>Join our community</td><td><a href="https://www.gitbook.com/">https://www.gitbook.com/</a></td></tr><tr><td><h4><i class="fa-computer-mouse">:computer-mouse:</i></h4></td><td><strong>Admin</strong></td><td>Manage your account</td><td><a href="https://www.gitbook.com/">https://www.gitbook.com/</a></td></tr><tr><td><h4><i class="fa-bullhorn">:bullhorn:</i></h4></td><td><strong>Product updates</strong></td><td>See what’s new</td><td><a href="https://www.gitbook.com/">https://www.gitbook.com/</a></td></tr></tbody></table>


