Skip to content

302ai/ai-sdk

Repository files navigation

302 AI SDK

This is an official provider SDK for 302AI that integrates with Vercel AI SDK.

Overview

The 302AI provider enables seamless integration with the Vercel AI SDK, offering access to a wide range of AI models for:

Text Generation

  • Advanced language models including:
    • GPT-4 series (gpt-4-turbo, gpt-4o, etc.)
    • Claude-3 series (opus, sonnet, haiku)
    • Gemini series
    • Llama 3 series
    • And many other leading models

Image Generation

  • State-of-the-art image models including:
    • Midjourney 6.0/6.1
    • DALL-E 3
    • Stable Diffusion variants (SD3, SDXL)
    • Flux models
    • Ideogram models
    • Playground models
    • Omnigen models
    • And more specialized image generators

Embeddings

  • High-quality embedding models including:
    • OpenAI text-embedding-3 (small/large)
    • BGE models
    • Zhipu embeddings
    • And other specialized embedding models

All models are accessible through a unified, type-safe API that follows Vercel AI SDK standards. For a complete list of supported models, please refer to our detailed documentation.

Features

  • 🚀 Simple, unified API for all AI operations
  • 💪 Full TypeScript support
  • 🔄 Streaming responses support
  • 🛡️ Built-in error handling
  • 📝 Comprehensive documentation

Installation

npm install @302ai/ai-sdk

Quick Start

import { ai302 } from '@302ai/ai-sdk';
import { generateText } from 'ai';

// Text Generation
const { text } = await generateText({
  model: ai302('gpt-4-turbo'),
  prompt: 'Hello, how can I help you today?'
});

// Image Generation
import { experimental_generateImage as generateImage } from 'ai';

const { image } = await generateImage({
  model: ai302.image('midjourney/6.1'),
  prompt: 'A beautiful sunset over mountains'
});

// Embeddings
import { embed } from 'ai';

const { embedding } = await embed({
  model: ai302.textEmbeddingModel('text-embedding-3-large'),
  value: 'Text to embed'
});

What's inside?

This SDK includes the following packages:

Packages

Each package is 100% TypeScript.

Documentation

For detailed documentation about available models and usage, please check:

License

Apache License 2.0 - See LICENSE for details.