Agent skill · Backend & API

api-ai-together-ai

Together AI SDK patterns for TypeScript — client setup, chat completions, streaming, structured output, function calling, embeddings, image generation, fine-tuning, and OpenAI-compatible endpoints

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill api-ai-together-ai --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 19 KB
Bundled scripts: none
Path: skills/ai-llm/api-ai-together-ai/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Describes how to use the Together AI SDK (together-ai) to access open-source models through Together AI's API. It outlines patterns for client setup, chat completions, streaming, structured output with JSON schema, function calling with a tools parameter, image generation, embeddings, and fine-tuning. It also notes compatibility with the OpenAI-like API shape and how to switch base URLs for OpenAI SDK compatibility.

How it works

The skill instructs using the together-ai package (import Together from "together-ai") to initialize a client (env var TOGETHER_API_KEY). It covers:

  • Client setup with retries, timeouts, and logging via a configured client instance
  • Chat completions using model IDs like meta-llama/Llama-3.3-70B-Instruct-Turbo and a messages array with system and user roles
  • Streaming via stream: true and consuming with for await...of
  • Structured output by including response_format: { type: "json_schema" } and a JSON schema in both the system prompt and response_format
  • Function calling / tool use with a tools array containing function definitions and strict mode
  • Image generation via client.images.generate with model and prompt
  • Embeddings via client.embeddings.create with a model and input
  • Error handling using Together.APIError and subclasses, with specific branches for RateLimitError and AuthenticationError
  • OpenAI compatibility by optionally using baseURL to api.together.xyz/v1

It also lists critical requirements and examples covering core patterns, and provides guidance on when to use or not use Together AI features.

When to use it

  • Running open-source LLMs (Llama, Qwen, Mistral, DeepSeek) via serverless inference
  • Generating images with FLUX or Stable Diffusion models
  • Creating embeddings for RAG pipelines with open-source models
  • Using function calling / tool use with open-source models
  • Extracting structured JSON output from LLM responses
  • Fine-tuning open-source models on custom data
  • Migrating from OpenAI to open-source models with minimal code changes

What it can touch

The skill references the following tools and methods that the agent can call: the Together client initialization and the methods under client.chat.completions, client.images, client.embeddings, and error types like Together.APIError, Together.RateLimitError, Together.AuthenticationError. It also specifies using the environment variable TOGETHER_API_KEY for credentials. Commands and file names are quoted exactly as shown in the guidance (e.g., import Together from "together-ai", client.chat.completions.create, response_format, tools parameter).

Caveats

  • Requires environment variable TOGETHER_API_KEY; keys must not be hardcoded
  • Some OpenAI-specific features are not recommended here; for OpenAI-exclusive features, use the OpenAI SDK directly
  • Returns and behaviors depend on model capabilities and the Together AI serverless inference service
From the SKILL.md

# Together AI SDK Patterns > **Quick Guide:** Use the `together-ai` npm package to access 200+ open-source models (Llama, Qwen, Mistral, DeepSeek) via Together AI's fast inference API. The SDK mirrors the OpenAI API shape -- `client.chat.completions.create()` for chat, `client.images.generate()` for images, `client.embeddings.create()` for embeddings. Use `response_format: { type: "json_schema" }` with Zod-generated schemas for structured output. Function calling uses the same `tools` parameter shape as OpenAI. You can also use the OpenAI SDK directly by pointing `baseURL` to `https://api.together.xyz/v1`. --- <critical_requirements> ## CRITICAL: Before Using This Skill > **All code must follow project conventions in CLAUDE.md** (kebab-case, named exports, import ordering, `import type`, named constants) **(You MUST use the `together-ai` package (`import Together from "together-ai"`) -- NOT the OpenAI SDK -- unless explicitly building an OpenAI-compatible integration)** **(You MUST include the JSON schema in BOTH the `response_format` parameter AND the system prompt when using structured output -- the model needs both)** **(You MUST handle errors using `Together.APIError` and its s

What's inside
Steps it walks through
  1. CRITICAL: Before Using This Skill
  2. Examples Index
  3. Philosophy
  4. Core Patterns
  5. Pattern 1: Client Setup
  6. Pattern 2: Chat Completions
  7. Pattern 3: Streaming
  8. Pattern 4: Structured Output with JSON Schema
  9. Pattern 5: Function Calling / Tool Use
  10. Pattern 6: Image Generation
  11. Pattern 7: Embeddings
  12. Pattern 8: Error Handling
  13. Performance Optimization
  14. Model Selection for Cost/Speed
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the api-ai-together-ai skill do?

Together AI SDK patterns for TypeScript — client setup, chat completions, streaming, structured output, function calling, embeddings, image generation, fine-tuning, and OpenAI-compatible endpoints

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill api-ai-together-ai --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going