Skip to content

diskd-ai/together-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Together AI API Skill

Install: npx skills add diskd-ai/together-api | skills.sh

Integration skill for building AI-powered applications with Together AI's open-source model inference platform.


Scope & Purpose

This skill provides guidance and patterns for working with Together AI's API, covering:

  • Chat completions with 200+ open-source models
  • Vision/image understanding
  • Image generation (FLUX, Stable Diffusion)
  • Audio transcription (Whisper) and text-to-speech
  • Tool use/function calling
  • Structured outputs and JSON mode
  • Embeddings

When to Use This Skill

Triggers:

  • Mentions of Together AI, Together API, or GroqCloud
  • Working with open-source LLM inference
  • Using Python SDK (together) or TypeScript SDK (together-ai)
  • Tasks involving FLUX image generation or Whisper transcription via Together

Use cases:

  • Implementing chat completions with Llama, DeepSeek, Qwen, or other open-source models
  • Adding vision capabilities with Llama 4 multimodal models
  • Generating images with FLUX or Stable Diffusion
  • Transcribing audio with Whisper
  • Building agents with tool use/function calling
  • Creating embeddings for RAG or semantic search

Quick Reference

Installation

# Python
pip install together

# TypeScript/JavaScript
npm install together-ai

Environment

export TOGETHER_API_KEY=<your-api-key>

Basic Usage

Python:

from together import Together

client = Together()  # Uses TOGETHER_API_KEY env var

response = client.chat.completions.create(
    model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
    messages=[{"role": "user", "content": "Hello"}]
)

TypeScript:

import Together from "together-ai";

const client = new Together();

const response = await client.chat.completions.create({
    model: "meta-llama/Llama-3.3-70B-Instruct-Turbo",
    messages: [{ role: "user", content: "Hello" }],
});

Model Selection Guide

Use Case Model Notes
Fast + cheap meta-llama/Llama-3.2-3B-Instruct-Turbo Best for simple tasks
Balanced meta-llama/Llama-3.3-70B-Instruct-Turbo Quality/cost balance
Highest quality deepseek-ai/DeepSeek-V3 163K context
Reasoning deepseek-ai/DeepSeek-R1 Chain-of-thought
Vision meta-llama/Llama-4-Scout-17B-16E-Instruct Image understanding
Code Qwen/Qwen2.5-Coder-32B-Instruct Code generation
Audio STT openai/whisper-large-v3 Transcription
TTS canopylabs/orpheus-3b Text-to-speech
Image Gen black-forest-labs/FLUX.1-schnell Fast image generation

Skill Structure

together-api/
  SKILL.md          # Full API reference and patterns
  README.md         # This file (overview)
  references/       # Supporting documentation
    models.md       # Complete model list and pricing
    tool-use.md     # Function calling patterns
    vision.md       # Image/video processing
    audio.md        # Transcription and TTS
    images.md       # Image generation

Key Patterns

Streaming Responses

stream = client.chat.completions.create(
    model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

JSON Mode

response = client.chat.completions.create(
    model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
    messages=[{"role": "user", "content": "List 3 colors as JSON array"}],
    response_format={"type": "json_object"}
)

Vision (Image from URL)

response = client.chat.completions.create(
    model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
        ]
    }]
)

Image Generation

response = client.images.generate(
    prompt="A serene mountain landscape at sunset",
    model="black-forest-labs/FLUX.1-schnell",
    steps=4,
    width=1024,
    height=1024
)

Error Handling

from together import Together
from together._exceptions import RateLimitError, APIConnectionError, APIStatusError

client = Together()

try:
    response = client.chat.completions.create(
        model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
        messages=[{"role": "user", "content": "Hello"}]
    )
except RateLimitError:
    # Wait and retry with exponential backoff
    pass
except APIConnectionError:
    # Network issue
    pass
except APIStatusError as e:
    # API error (check e.status_code)
    pass

Resources


License

MIT

About

Together AI API skill for Claude Code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published