Skip to main content

Overview

We’re excited to announce the release of Python v2, an upgrade to the Together AI Python SDK. This guide will help you migrate from the legacy (v1) SDK to the new version. Why Migrate? The new SDK offers several advantages:
  • Modern Architecture: Built with Stainless OpenAPI generator for consistency and reliability
  • Better Type Safety: Comprehensive typing for better IDE support and fewer runtime errors
  • Broader Python Support: Python 3.8+ (vs 3.10+ in legacy)
  • Modern HTTP Client: Uses httpx instead of requests
  • Faster Performance: ~20ms faster per request on internal benchmarks
  • uv Support: Compatible with uv, the fast Python package installer - uv add together

Feature Parity Matrix

Use this table to quickly assess the migration effort for your specific use case: Legend: ✅ No changes | ⚠️ Minor changes needed | 🆕 New capability

Installation & Setup

1. Install the New SDK
2. Dependency Changes The new SDK uses different dependencies. You can remove legacy dependencies if not used elsewhere: Old dependencies (can remove):
New dependencies (automatically installed):
3. Client Initialization Basic client setup remains the same:
Some constructor parameters have changed. See Constructor Parameters for details.

Global Breaking Changes

Constructor Parameters

The client constructor has been updated with renamed and new parameters:
Key Changes:
  • supplied_headersdefault_headers (renamed)
  • New optional parameters: default_query, http_client

Keyword-Only Arguments

All API method arguments must now be passed as keyword arguments. Positional arguments are no longer supported.

Optional Parameters

The new SDK uses NOT_GIVEN instead of None for omitted optional parameters. In most cases, you can simply omit the parameter entirely:

Extra Parameters

The legacy **kwargs pattern has been replaced with explicit parameters for passing additional data:

Response Type Names

Most API methods have renamed response type definitions. If you’re importing response types for type hints, you’ll need to update your imports:

CLI Commands Removed

The following CLI commands have been removed in the new SDK:
  • together chat.completions
  • together completions
  • together images generate

APIs with No Changes Required

The following APIs work identically in both SDKs. No code changes are needed: Chat Completions
Streaming
Embeddings
Images
Videos
Rerank
Rerank models like mxbai-rerank-large-v2 are only available with dedicated model inference. You can bring up a dedicated endpoint to use reranking in your applications.
Fine-tuning (Basic Operations)

APIs with Changes Required

Batches Method names have been simplified, and the response structure has changed slightly.
Key Changes:
  • create_batch()create()
  • get_batch()retrieve()
  • list_batches()list()
  • cancel_batch()cancel()
  • file_idinput_file_id
  • create() returns full response; access .job for the job object
Endpoints
Key Changes:
  • get()retrieve()
  • min_replicas and max_replicas are now nested inside autoscaling parameter
  • list() response changed: previously returned array directly, now returns object with .data
Files
Key Changes:
  • retrieve_content()content()
  • No longer writes to disk automatically; returns binary data for you to handle
Fine-tuning Checkpoints
Key Changes:
  • Response is now an object with .data containing the list of checkpoints
  • Checkpoint properties renamed: typecheckpoint_type, timestampcreated_at
  • name no longer exists; construct from ft_id and step
Fine-tuning Download
Key Changes:
  • download()content() with streaming response
  • No longer writes to disk automatically
Code Interpreter
Key Changes:
  • run()execute()
  • Output access: result.outputresult.data.outputs[0].data
  • New sessions.list() method for session management
Audio Transcriptions & Translations The new SDK requires file objects instead of file paths for audio operations. Use context managers for proper resource handling.
Key Changes:
  • File paths (strings) → file objects opened with open(file, "rb")
  • Use context managers (with open(...) as f:) for proper resource cleanup
Audio Speech (TTS) - Voice Listing When listing available voices, voice properties are now accessed as object attributes instead of dictionary keys.
Key Changes:
  • Voice properties: voice['name']voice.name (dict access → attribute access)
Evaluations The evaluations API has significant changes including a namespace rename and restructured parameters.
Key Changes:
  • Namespace: client.evaluationclient.evals
  • Parameters restructured with typed parameter objects
  • retrieve() and status() no longer use named arguments

New SDK-Only Features

Raw Response Access Access raw HTTP responses for debugging:
Streaming with Context Manager Better resource management for streaming:

Error Handling Migration

The exception hierarchy has been completely restructured with a new, more granular set of HTTP status-specific exceptions. Update your error handling code accordingly: New exceptions added:
  • PermissionDeniedError (403)
  • NotFoundError (404)
  • ConflictError (409)
  • UnprocessableEntityError (422)
Exception attributes have changed. For example, http_status is now status_code. Check your error handling code for attribute access.
Updated Error Handling Example

Troubleshooting

Import Errors Problem:
Solution: Response type imports have changed:
Method Not Found Errors Problem:
Solution: Method names have been simplified:
Parameter Type Errors Problem:
Solution: Don’t pass None for optional parameters; omit them instead:
Namespace Errors Problem:
Solution: The namespace was renamed:

Best Practices

Type Safety Take advantage of improved typing:
HTTP Client Configuration The new SDK uses httpx. Configure it as needed:

Getting Help

If you encounter issues during migration: