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

# Tensormesh AI SDK Provider

> Use Tensormesh serverless inference from JavaScript and TypeScript applications through the AI SDK.

`@tensormesh/ai-sdk-provider` adds Tensormesh language models to the Vercel AI SDK. JavaScript and TypeScript applications can use AI SDK functions such as `generateText` and `streamText` while requests are sent to Tensormesh text inference endpoints.

Calling `tensormesh(modelId)` creates a chat model backed by `/v1/chat/completions`. Calling `tensormesh.completionModel(modelId)` creates a completion model backed by `/v1/completions`. Structured output and tool calling are requested through chat model calls. Raw helpers expose additional inference endpoints such as `/v1/responses`.

## Install

```bash theme={null}
npm install ai @tensormesh/ai-sdk-provider
```

The package requires Node.js 20 or newer.

## What It Supports

* Serverless inference by default at `https://serverless.tensormesh.ai/v1`
* Text generation and streaming with chat models over `/v1/chat/completions`
* Text completions over `/v1/completions`
* Structured output through AI SDK chat model calls
* Tool calling through AI SDK chat model calls
* Model-specific reasoning controls through `providerOptions.tensormesh.chat_template_kwargs`
* Direct helper methods for `/v1/models`, `/v1/responses`, `/tokenize`, `/detokenize`, `/health`, and `/version`

## Provider API

```ts theme={null}
import { createTensormesh, tensormesh } from "@tensormesh/ai-sdk-provider";

// Default serverless provider.
const model = tensormesh("deepseek-ai/DeepSeek-V4-Flash");

// Explicit provider configuration.
const serverless = createTensormesh({
  apiKey: process.env.TENSORMESH_INFERENCE_API_KEY,
});
```

The default provider instance, `tensormesh`, is equivalent to
`createTensormesh()` with serverless defaults. Authenticated requests read
`TENSORMESH_INFERENCE_API_KEY` unless you pass `apiKey` explicitly.
Importing or creating a provider instance does not require an API key.

## Common Guides

* [Getting started](/ai-sdk/guides/getting-started)
* [Provider configuration](/ai-sdk/guides/provider-configuration)
* [Chat and streaming](/ai-sdk/guides/chat-and-streaming)
* [Structured output](/ai-sdk/guides/structured-output)
* [Tool calling](/ai-sdk/guides/tool-calling)
* [Reasoning controls](/ai-sdk/guides/reasoning-controls)
* [Raw inference helpers](/ai-sdk/guides/raw-helpers)
* [Playground](/ai-sdk/guides/playground)
