Skip to main content

A set of utils to make Together AI API easier to use. Implements the utils for the model fine-tuning and simplified endpoint fetching. Uses the official Together AI API and builds up on it (https://github.com/togethercomputer/together-python).

Project description

Together AI API Helper

A Python package that provides high-level utilities for working with Together AI's API, making endpoint management and fine-tuning operations simpler and more robust.

Features

🚀 Endpoint Management

  • Automatic endpoint provisioning and configuration
  • State monitoring and health checks
  • Hardware configuration management

🎯 Fine-Tuning Operations

  • Automated fine-tuning job lifecycle management
  • Real-time job monitoring with event streaming
  • Training file validation and upload
  • Automatic Hugging Face repository creation

Installation

Install the package from PyPI:

uv add together-ai-api-helper

Requirements

  • Python ≥ 3.13
  • Together AI API key
  • Hugging Face token (if you want to upload the fine-tuned models)

Setup

1. API tokens

Set your API keys as environment variables. (Note that the HF_TOKEN is optional and is only needed if you want to automatically upload the trained model to HF):

export TOGETHER_API_KEY="your-api-key-here"
export HF_TOKEN="your-hf-token-here"

Usage

Endpoint Management

from together_ai_api_helper.endpoints import EndpointClient, EndpointConfig, GenerateConfig

# Initialize the client
client = EndpointClient()

# Configure your endpoint
config = EndpointConfig(
    model_name="mistralai/Mistral-7B-Instruct-v0.1",
    display_name="My Mistral Endpoint",
    # Uses cheapest compatible hardware by default
)

# Get or create an endpoint
endpoint_name, endpoint_id = client.get_endpoint_for_model(config)
print(f"Endpoint ready: {endpoint_name} ({endpoint_id})")

Fine-Tuning

from together_ai_api_helper.training import TrainingClient, TrainingConfig

# Initialize the training client
client = TrainingClient()

# Configure your training job
config = TrainingConfig(
    model="mistralai/Mistral-7B-Instruct-v0.1",
    training_file="path/to/your/training_data.jsonl",
    suffix="my-custom-model",
    n_epochs=3,
    learning_rate=1e-5,
    **other_together_ai_params
)

# Train the model (this will monitor progress automatically)
model_name = client.start_job(config)

Logging

All operations are logged with detailed information. Logs include:

  • Endpoint state changes
  • Training progress and events
  • Error messages and debugging information
  • API interactions and timing

Log files are created automatically (can change the file paths):

  • endpoints.log for endpoint operations
  • training.log for fine-tuning operations

API Reference

EndpointClient Methods

  • get_endpoint_for_model(config) - Get or create an endpoint
  • list_active_endpoints() - List all active endpoints
  • list_inactive_endpoints() - List all inactive endpoints
  • restart_endpoint(endpoint_id) - Restart a stopped endpoint
  • stop_endpoint(endpoint_id) - Stop a running endpoint
  • delete_endpoint(endpoint_id) - Delete an endpoint

TrainingClient Methods

  • start_job(config) - Start and monitor a fine-tuning job
  • monitor_job(job_id) - Monitor an existing job
  • cancel_job(job_id) - Cancel a running job

Contributing

This package builds on top of the official Together Python SDK.

For development use the dev extra dependencies:

uv sync --extra dev

Note that the linting and type checking will run automatically in pre-commit.

License

MIT License

Support

For issues and questions:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

together_ai_api_helper-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

together_ai_api_helper-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file together_ai_api_helper-0.1.0.tar.gz.

File metadata

File hashes

Hashes for together_ai_api_helper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 834b94a454ce27acd33a99262b62324eb20041c2a43adca92a7839faff07aeaf
MD5 4443d64c9c258bfea84390d8e6c3dcd0
BLAKE2b-256 6ad9d4376e6fd04aeacda56ce10601e885b0723a464096da743dbdd3b29d9f70

See more details on using hashes here.

File details

Details for the file together_ai_api_helper-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for together_ai_api_helper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1ba21c87940f0d829985eacf478775b7ee73068dbad61e8ad73fd8a9a85a36c
MD5 4e4bc2a4e55b463c038daa438dcccd66
BLAKE2b-256 7479f840203ed0c4dda613066a61ad59c7413a5b72053b2ae6d42a45b630beb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page