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.logfor endpoint operationstraining.logfor fine-tuning operations
API Reference
EndpointClient Methods
get_endpoint_for_model(config)- Get or create an endpointlist_active_endpoints()- List all active endpointslist_inactive_endpoints()- List all inactive endpointsrestart_endpoint(endpoint_id)- Restart a stopped endpointstop_endpoint(endpoint_id)- Stop a running endpointdelete_endpoint(endpoint_id)- Delete an endpoint
TrainingClient Methods
start_job(config)- Start and monitor a fine-tuning jobmonitor_job(job_id)- Monitor an existing jobcancel_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:
- Check the Together AI documentation
- Review the official Together Python SDK
- Open an issue in this repository
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file together_ai_api_helper-0.1.0.tar.gz.
File metadata
- Download URL: together_ai_api_helper-0.1.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
834b94a454ce27acd33a99262b62324eb20041c2a43adca92a7839faff07aeaf
|
|
| MD5 |
4443d64c9c258bfea84390d8e6c3dcd0
|
|
| BLAKE2b-256 |
6ad9d4376e6fd04aeacda56ce10601e885b0723a464096da743dbdd3b29d9f70
|
File details
Details for the file together_ai_api_helper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: together_ai_api_helper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1ba21c87940f0d829985eacf478775b7ee73068dbad61e8ad73fd8a9a85a36c
|
|
| MD5 |
4e4bc2a4e55b463c038daa438dcccd66
|
|
| BLAKE2b-256 |
7479f840203ed0c4dda613066a61ad59c7413a5b72053b2ae6d42a45b630beb2
|