Supported Features

The Aihubmix provider supports the following AI features, so your product is no longer limited to being LLM-driven:
  • Text Generation: Generate text content using various models
  • Streaming Text: Real-time text streaming
  • Image Generation: Create images from text prompts
  • Vector Embeddings: Single and batch text embeddings
  • Object Generation: Structured data generation
  • Streaming Objects: Real-time structured data streaming
  • Speech Synthesis: Text-to-speech
  • Transcription: Speech-to-text
  • Tools: Web search and other tools

Installation

Aihubmix is available in the @aihubmix/ai-sdk-provider module. Install it via @aihubmix/ai-sdk-provider:
npm i @aihubmix/ai-sdk-provider@0.0.1

Provider Instance

You can import the default provider instance, aihubmix, from @aihubmix/ai-sdk-provider:
import { aihubmix } from '@aihubmix/ai-sdk-provider';

Configuration

Set your Aihubmix API key as an environment variable for secure access:
export AIHUBMIX_API_KEY="your-api-key-here"
Or pass it directly to the provider:
import { createAihubmix } from '@aihubmix/ai-sdk-provider';

const aihubmix = createAihubmix({
  apiKey: 'your-api-key-here',
});

Usage

Import the necessary functions:
import { createAihubmix } from '@aihubmix/ai-sdk-provider';
import { 
  generateText, 
  streamText, 
  generateImage, 
  embed, 
  embedMany, 
  generateObject, 
  streamObject, 
  generateSpeech, 
  transcribe 
} from 'ai';
import { z } from 'zod';
Examples of various types of AI generation calls:
import { aihubmix } from '@aihubmix/ai-sdk-provider';
import { generateText } from 'ai';

const { text } = await generateText({
  model: aihubmix('o4-mini'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});