> For the complete documentation index, see [llms.txt](https://docs.tensorx.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorx.ai/api-reference/overview.md).

# 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": "deepseek/deepseek-chat-v3.1",
    "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": "deepseek/deepseek-chat-v3.1",
  "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](https://github.com/Tensorix-ai/tensorix-docs/blob/main/api-reference/chat-completions/README.md) - Create chat completions
* [Models](https://github.com/Tensorix-ai/tensorix-docs/blob/main/api-reference/models/README.md) - View available models
* [API Examples](https://github.com/Tensorix-ai/tensorix-docs/blob/main/api-examples/README.md) - Code examples in multiple languages


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tensorx.ai/api-reference/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
