Together AI SDK (v2)
from together import Together
import os
client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)
result = client.endpoints.adapters.add(
"endpoint-abc123",
model_id="username/my-endpoint-name:username/my-adapter-model",
)
print(result.api_model_id)import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const result = await client.endpoints.adapters.add("endpoint-abc123", {
model_id: "username/my-endpoint-name:username/my-adapter-model",
});
console.log(result.model_id);import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const result = await client.endpoints.adapters.add("endpoint-abc123", {
model_id: "username/my-endpoint-name:username/my-adapter-model",
});
console.log(result.model_id);curl -X POST "https://api.together.ai/v1/endpoints/endpoint-abc123/adapters" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model_id": "username/my-endpoint-name:username/my-adapter-model"}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/endpoints/{endpointId}/adapters",
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_id' => 'username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123'
]),
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/endpoints/{endpointId}/adapters"
payload := strings.NewReader("{\n \"model_id\": \"username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123\"\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/endpoints/{endpointId}/adapters")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_id\": \"username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/endpoints/{endpointId}/adapters")
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_id\": \"username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123\"\n}"
response = http.request(request)
puts response.read_body{
"model_id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}Endpoints
Add a LoRA adapter to an endpoint
Adds a LoRA adapter model to a dedicated endpoint. After this call, inference requests to the adapter model name will be routed to the specified endpoint. The endpoint must have LoRA enabled, and the adapter’s base model must be compatible with the endpoint’s model. The endpoint name prefix in model_id must match the resolved endpoint.
POST
/
endpoints
/
{endpointId}
/
adapters
Together AI SDK (v2)
from together import Together
import os
client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)
result = client.endpoints.adapters.add(
"endpoint-abc123",
model_id="username/my-endpoint-name:username/my-adapter-model",
)
print(result.api_model_id)import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const result = await client.endpoints.adapters.add("endpoint-abc123", {
model_id: "username/my-endpoint-name:username/my-adapter-model",
});
console.log(result.model_id);import Together from "together-ai";
const client = new Together({
apiKey: process.env.TOGETHER_API_KEY,
});
const result = await client.endpoints.adapters.add("endpoint-abc123", {
model_id: "username/my-endpoint-name:username/my-adapter-model",
});
console.log(result.model_id);curl -X POST "https://api.together.ai/v1/endpoints/endpoint-abc123/adapters" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model_id": "username/my-endpoint-name:username/my-adapter-model"}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/endpoints/{endpointId}/adapters",
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_id' => 'username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123'
]),
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/endpoints/{endpointId}/adapters"
payload := strings.NewReader("{\n \"model_id\": \"username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123\"\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/endpoints/{endpointId}/adapters")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_id\": \"username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/endpoints/{endpointId}/adapters")
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_id\": \"username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123\"\n}"
response = http.request(request)
puts response.read_body{
"model_id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The endpoint ID
Body
application/json
Combined identifier in format "endpoint_name:adapter_model_name".
Example:
"username/Meta-Llama-3.1-8B-Instruct-def456:username/my-adapter-abc123"
Response
Adapter successfully bound to endpoint
Was this page helpful?
⌘I