vantedge-ai-sdk
v0.1.1
Published
VantEdge AI SDK provider for AI SDK
Maintainers
Readme
vantedge-ai-sdk
VantEdge AI SDK provider for AI SDK - A custom provider that implements OpenAI-compatible endpoints for AI SDK.
Installation
npm install vantedge-ai-sdkUsage
Basic Usage
import { vantedgeai } from 'vantedge-ai-sdk';
import { generateText } from 'ai';
const { text } = await generateText({
model: vantedgeai('your-model-id'),
prompt: 'Hello, how are you?',
});Chat Model
import { vantedgeai } from 'vantedge-ai-sdk';
import { streamText } from 'ai';
const { textStream } = await streamText({
model: vantedgeai.chatModel('your-chat-model-id'),
messages: [{ role: 'user', content: 'Hello, how are you?' }],
});Completion Model
import { vantedgeai } from 'vantedge-ai-sdk';
import { generateText } from 'ai';
const { text } = await generateText({
model: vantedgeai.completionModel('your-completion-model-id'),
prompt: 'Complete this sentence: The weather today is',
});Embedding Model
import { vantedgeai } from 'vantedge-ai-sdk';
import { embed } from 'ai';
const { embedding } = await embed({
model: vantedgeai.textEmbeddingModel('your-embedding-model-id'),
value: 'This is a sample text to embed.',
});Image Model
import { vantedgeai } from 'vantedge-ai-sdk';
import { generateImage } from 'ai';
const { image } = await generateImage({
model: vantedgeai.imageModel('your-image-model-id'),
prompt: 'A beautiful sunset over the ocean',
});Configuration
Custom Provider Instance
import { createVantEdgeAI } from 'vantedge-ai-sdk';
const customProvider = createVantEdgeAI({
apiKey: 'your-api-key',
baseURL: 'https://your-api-endpoint.com/v1',
headers: {
'Custom-Header': 'custom-value',
},
queryParams: {
version: '2024-01-01',
},
});
// Use the custom provider
const { text } = await generateText({
model: customProvider('your-model-id'),
prompt: 'Hello world',
});Environment Variables
You can set the API key using environment variables:
export VANTEDGE_API_KEY="your-api-key"API Reference
createVantEdgeAI(options)
Creates a custom VantEdge AI provider instance.
Options
apiKey(string, optional): Your VantEdge AI API keybaseURL(string, optional): Base URL for API calls (default: environment-specific)headers(Record<string, string>, optional): Custom headers to include in requestsqueryParams(Record<string, string>, optional): Custom query parametersfetch(FetchFunction, optional): Custom fetch implementation
vantedgeai
Default provider instance with default configuration.
Model IDs
The package supports various model types:
- Chat Models: Use with
vantedgeai()orvantedgeai.chatModel() - Completion Models: Use with
vantedgeai.completionModel() - Embedding Models: Use with
vantedgeai.textEmbeddingModel() - Image Models: Use with
vantedgeai.imageModel()
Features
- ✅ OpenAI-compatible API endpoints
- ✅ Support for chat, completion, embedding, and image models
- ✅ Customizable headers and query parameters
- ✅ Environment variable support for API keys
- ✅ TypeScript support with full type definitions
- ✅ Custom fetch implementation support
- ✅ Thread ID management for conversation context
Requirements
- Node.js 18+
- AI SDK 1.0+
License
Apache 2.0
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
