from together import Together
import os
client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)
response = client.models.upload(
model_name="My-Fine-Tuned-Model",
model_source="https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
)
print(response.data.job_id)import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const response = await client.models.upload({
model_name: "My-Fine-Tuned-Model",
model_source: "https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
})
console.log(response);
import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const response = await client.models.upload({
model_name: "My-Fine-Tuned-Model",
model_source: "https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
})
console.log(response);
curl -X POST "https://api.together.ai/v1/models" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_name": "My-Fine-Tuned-Model",
"model_source": "https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/models",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_name' => 'Qwen2.5-72B-Instruct',
'model_source' => 'unsloth/Qwen2.5-72B-Instruct',
'model_type' => 'model',
'hf_token' => 'hf_examplehuggingfacetoken',
'description' => 'Finetuned Qwen2.5-72B-Instruct by Unsloth',
'base_model' => 'Qwen/Qwen2.5-72B-Instruct',
'lora_model' => 'my_username/Qwen2.5-72B-Instruct-lora'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.together.ai/v1/models"
payload := strings.NewReader("{\n \"model_name\": \"Qwen2.5-72B-Instruct\",\n \"model_source\": \"unsloth/Qwen2.5-72B-Instruct\",\n \"model_type\": \"model\",\n \"hf_token\": \"hf_examplehuggingfacetoken\",\n \"description\": \"Finetuned Qwen2.5-72B-Instruct by Unsloth\",\n \"base_model\": \"Qwen/Qwen2.5-72B-Instruct\",\n \"lora_model\": \"my_username/Qwen2.5-72B-Instruct-lora\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.together.ai/v1/models")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_name\": \"Qwen2.5-72B-Instruct\",\n \"model_source\": \"unsloth/Qwen2.5-72B-Instruct\",\n \"model_type\": \"model\",\n \"hf_token\": \"hf_examplehuggingfacetoken\",\n \"description\": \"Finetuned Qwen2.5-72B-Instruct by Unsloth\",\n \"base_model\": \"Qwen/Qwen2.5-72B-Instruct\",\n \"lora_model\": \"my_username/Qwen2.5-72B-Instruct-lora\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/models")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_name\": \"Qwen2.5-72B-Instruct\",\n \"model_source\": \"unsloth/Qwen2.5-72B-Instruct\",\n \"model_type\": \"model\",\n \"hf_token\": \"hf_examplehuggingfacetoken\",\n \"description\": \"Finetuned Qwen2.5-72B-Instruct by Unsloth\",\n \"base_model\": \"Qwen/Qwen2.5-72B-Instruct\",\n \"lora_model\": \"my_username/Qwen2.5-72B-Instruct-lora\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"job_id": "job-a15dad11-8d8e-4007-97c5-a211304de284",
"model_name": "necolinehubner/Qwen2.5-72B-Instruct",
"model_id": "model-c0e32dfc-637e-47b2-bf4e-e9b2e58c9da7",
"model_source": "huggingface"
},
"message": "Processing model weights. Job created."
}Upload a custom model or adapter
Upload a custom model or adapter from Hugging Face or S3
from together import Together
import os
client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)
response = client.models.upload(
model_name="My-Fine-Tuned-Model",
model_source="https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
)
print(response.data.job_id)import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const response = await client.models.upload({
model_name: "My-Fine-Tuned-Model",
model_source: "https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
})
console.log(response);
import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const response = await client.models.upload({
model_name: "My-Fine-Tuned-Model",
model_source: "https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
})
console.log(response);
curl -X POST "https://api.together.ai/v1/models" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_name": "My-Fine-Tuned-Model",
"model_source": "https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/models",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_name' => 'Qwen2.5-72B-Instruct',
'model_source' => 'unsloth/Qwen2.5-72B-Instruct',
'model_type' => 'model',
'hf_token' => 'hf_examplehuggingfacetoken',
'description' => 'Finetuned Qwen2.5-72B-Instruct by Unsloth',
'base_model' => 'Qwen/Qwen2.5-72B-Instruct',
'lora_model' => 'my_username/Qwen2.5-72B-Instruct-lora'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.together.ai/v1/models"
payload := strings.NewReader("{\n \"model_name\": \"Qwen2.5-72B-Instruct\",\n \"model_source\": \"unsloth/Qwen2.5-72B-Instruct\",\n \"model_type\": \"model\",\n \"hf_token\": \"hf_examplehuggingfacetoken\",\n \"description\": \"Finetuned Qwen2.5-72B-Instruct by Unsloth\",\n \"base_model\": \"Qwen/Qwen2.5-72B-Instruct\",\n \"lora_model\": \"my_username/Qwen2.5-72B-Instruct-lora\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.together.ai/v1/models")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_name\": \"Qwen2.5-72B-Instruct\",\n \"model_source\": \"unsloth/Qwen2.5-72B-Instruct\",\n \"model_type\": \"model\",\n \"hf_token\": \"hf_examplehuggingfacetoken\",\n \"description\": \"Finetuned Qwen2.5-72B-Instruct by Unsloth\",\n \"base_model\": \"Qwen/Qwen2.5-72B-Instruct\",\n \"lora_model\": \"my_username/Qwen2.5-72B-Instruct-lora\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/models")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_name\": \"Qwen2.5-72B-Instruct\",\n \"model_source\": \"unsloth/Qwen2.5-72B-Instruct\",\n \"model_type\": \"model\",\n \"hf_token\": \"hf_examplehuggingfacetoken\",\n \"description\": \"Finetuned Qwen2.5-72B-Instruct by Unsloth\",\n \"base_model\": \"Qwen/Qwen2.5-72B-Instruct\",\n \"lora_model\": \"my_username/Qwen2.5-72B-Instruct-lora\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"job_id": "job-a15dad11-8d8e-4007-97c5-a211304de284",
"model_name": "necolinehubner/Qwen2.5-72B-Instruct",
"model_id": "model-c0e32dfc-637e-47b2-bf4e-e9b2e58c9da7",
"model_source": "huggingface"
},
"message": "Processing model weights. Job created."
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The name to give to your uploaded model
"Qwen2.5-72B-Instruct"
The source location of the model (Hugging Face repo or S3 path)
"unsloth/Qwen2.5-72B-Instruct"
Whether the model is a full model or an adapter
model, adapter "model"
Hugging Face token (if uploading from Hugging Face)
"hf_examplehuggingfacetoken"
A description of your model
"Finetuned Qwen2.5-72B-Instruct by Unsloth"
The base model to use for an adapter if setting it to run against a serverless pool. Only used for model_type adapter.
"Qwen/Qwen2.5-72B-Instruct"
The lora pool to use for an adapter if setting it to run against, say, a dedicated pool. Only used for model_type adapter.
"my_username/Qwen2.5-72B-Instruct-lora"
Was this page helpful?