Skip to main content

TopxAI

TopxAI is an API gateway that provides access to models from multiple AI providers through an OpenAI-compatible API. You can use its Chat Completions endpoint with the AI SDK through the @ai-sdk/openai-compatible module.

Setup

Install the OpenAI Compatible provider:

pnpm add @ai-sdk/openai-compatible
npm install @ai-sdk/openai-compatible
yarn add @ai-sdk/openai-compatible
bun add @ai-sdk/openai-compatible

Create a TopxAI API key, choose a route that includes the models you want to use, and set the key as a server-side environment variable:

export TOPXAI_API_KEY=your-api-key

See the TopxAI API key guide for details.

Provider Instance

Create a TopxAI provider instance with createOpenAICompatible:

import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const topxai = createOpenAICompatible({
  name: 'topxai',
  apiKey: process.env.TOPXAI_API_KEY,
  baseURL: 'https://ai.topxea.com/v1',
  includeUsage: true,
});

The apiKey setting sends the key as a Bearer token in the Authorization header. includeUsage: true requests usage information in streaming responses.

Language Models

Create a language model by passing a TopxAI model ID to the provider instance:

const model = topxai('kimi-k3');

Example

Use generateText to generate text with the model:

import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';

const topxai = createOpenAICompatible({
  name: 'topxai',
  apiKey: process.env.TOPXAI_API_KEY,
  baseURL: 'https://ai.topxea.com/v1',
  includeUsage: true,
});

const { text } = await generateText({
  model: topxai('kimi-k3'),
  prompt: 'Explain what an API gateway does in one sentence.',
});

console.log(text);

You can also use TopxAI language models with streamText.

Supported Models and Capabilities

TopxAI exposes the following text model IDs through its OpenAI-compatible Chat Completions endpoint:

ProviderModel IDs
Anthropicclaude-fable-5-1, claude-opus-5-5, claude-sonnet-5-5
OpenAIgpt-6-astra, gpt-6.1-sol
xAIgrok-4.7
Zhipu AIGLM-5.3-Abliterated
Moonshotkimi-k3
DeepSeekdeepseek-flash, deepseek-v4-pro

The available models and the routes enabled for a key can change. Use the authenticated GET /v1/models endpoint or the TopxAI model and pricing catalog for the current model IDs.

The jev-1.13.0 model in the TopxAI catalog uses a separate System One endpoint and is not available through this Chat Completions integration.

Supported capabilities depend on the selected model and include:

  • text generation and streaming;
  • tool calling, including multi-step tool use with stopWhen;
  • reasoning content and reasoning token usage for reasoning models such as deepseek-flash; and
  • structured output for models that support JSON Schema.

To send JSON Schema structured-output requests, enable supportsStructuredOutputs:

const topxai = createOpenAICompatible({
  name: 'topxai',
  apiKey: process.env.TOPXAI_API_KEY,
  baseURL: 'https://ai.topxea.com/v1',
  supportsStructuredOutputs: true,
});

This guide covers TopxAI's OpenAI-compatible Chat Completions endpoint. TopxAI also documents using the AI SDK OpenAI and Anthropic providers with its Responses and Messages APIs.

Resources