Integrate Together.ai language models into your AI SDK applications with support for Meta-Llama and other models hosted on the Together.ai platform.
Integrate Together.ai's language models into your AI SDK applications. This skill provides access to models hosted on the Together.ai platform, including Meta-Llama and other open-source models.
This skill helps you set up and use the Together.ai provider for the AI SDK, enabling you to:
When a user requests Together.ai integration with AI SDK, follow these steps:
Install the Together.ai provider package:
```bash
npm install @ai-sdk/togetherai
```
If the user doesn't have the base AI SDK installed:
```bash
npm install ai
```
Ensure the user has a Together.ai API key configured. Add to their `.env` file if not present:
```
TOGETHER_API_KEY=your_together_ai_api_key_here
```
Remind the user to:
Create or update the relevant file with the Together.ai provider:
```typescript
import { togetherai } from '@ai-sdk/togetherai';
```
Provide a working example based on the user's use case. Default example:
```typescript
import { togetherai } from '@ai-sdk/togetherai';
import { generateText } from 'ai';
const { text } = await generateText({
model: togetherai('meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'),
prompt: 'Write a Python function that sorts a list:',
});
console.log(text);
```
Common Together.ai models to suggest:
Adjust model selection based on user requirements (speed vs capability, cost considerations).
If the user needs more than basic text generation, mention these AI SDK capabilities:
Provide code examples only if the user specifically requests these features.
**Scenario 1: Simple text generation**
```typescript
import { togetherai } from '@ai-sdk/togetherai';
import { generateText } from 'ai';
const result = await generateText({
model: togetherai('meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'),
prompt: 'Explain quantum computing in simple terms',
});
```
**Scenario 2: Streaming responses**
```typescript
import { togetherai } from '@ai-sdk/togetherai';
import { streamText } from 'ai';
const { textStream } = await streamText({
model: togetherai('meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo'),
prompt: 'Write a story about AI',
});
for await (const chunk of textStream) {
process.stdout.write(chunk);
}
```
**Scenario 3: Structured output**
```typescript
import { togetherai } from '@ai-sdk/togetherai';
import { generateObject } from 'ai';
import { z } from 'zod';
const result = await generateObject({
model: togetherai('meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'),
schema: z.object({
recipe: z.object({
name: z.string(),
ingredients: z.array(z.string()),
steps: z.array(z.string()),
}),
}),
prompt: 'Generate a recipe for chocolate chip cookies',
});
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/togetherai-ai-sdk-integration/raw