@ezhang3/instantapply
v0.0.10
Published
InstantApply provider for Vercel AI SDK
Maintainers
Readme
InstantApply Provider for Vercel AI SDK
The InstantApply provider for the Vercel AI SDK contains language model support for the InstantApply API.
Setup
The InstantApply provider is available in the @relace/instantapply module.
npm install @relace/instantapplyProvider Instance
You can import the default provider instance instantapply from @relace/instantapply:
import { instantapply } from '@relace/instantapply';Example
import { instantapply } from '@relace/instantapply';
import { generateText } from 'ai';
const { text } = await generateText({
model: instantapply('instantapply/chat'),
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});Configuration
You can configure the InstantApply provider with various options:
import { createInstantApply } from '@relace/instantapply';
const instantapply = createInstantApply({
apiKey: 'your-api-key', // optional, defaults to INSTANTAPPLY_API_KEY env var
baseURL: 'https://api.instantapply.com/v1', // optional, defaults to InstantApply API
headers: {
'Custom-Header': 'value',
},
});Models
The InstantApply provider supports different types of models:
Chat Models
const model = instantapply.chatModel('instantapply/chat');Completion Models
const model = instantapply.completionModel('instantapply/completion');Embedding Models
const model = instantapply.textEmbeddingModel('instantapply/embedding');Model Settings
You can configure model-specific settings:
const model = instantapply('instantapply/chat', {
// OpenAI-compatible settings
temperature: 0.0,
maxTokens: 32000,
topP: 1,
// Add custom settings here
});Environment Variables
Set your InstantApply API key as an environment variable:
export INSTANTAPPLY_API_KEY="your-api-key"Error Handling
The provider handles errors according to the Vercel AI SDK error handling patterns:
import { generateText } from 'ai';
import { instantapply } from '@relace/instantapply';
try {
const { text } = await generateText({
model: instantapply('instantapply/chat'),
prompt: 'Hello world',
});
} catch (error) {
// Handle API errors
console.error('Error:', error);
}TypeScript Support
The provider includes full TypeScript support with proper type definitions for all model types and settings.
License
MIT
