For the complete documentation index, see llms.txt. This page is also available as Markdown.

LlamaIndex

LlamaIndex 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

Installation

pip install llama-index llama-index-llms-openai

Configuration

Basic Usage

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

Streaming Responses

RAG Applications

Build retrieval-augmented generation (RAG) systems with TensorX:

Agent Applications

Create agents with TensorX:

Configuration with Settings

For global configuration across your application:

Available Models

See TensorX 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:

Token limits

Adjust max_tokens based on your needs:

Resources

Last updated

Was this helpful?