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

Vercel AI SDK

The Vercel AI SDK 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

Installation

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

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:

Usage Examples

Text Generation

Streaming Text

Chat Completions

Structured Output

Next.js Integration

API Route (App Router)

React Component

Tool Calling

Available Models

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

Streaming not working

Ensure you're using streamText instead of generateText and returning toDataStreamResponse().

Resources

Last updated

Was this helpful?