Prepare a fine-tuned model for FP4 inference
Prepares a fine-tuned model for FP4 inference: an adapter is merged into its base model and the result quantized to FP4; a full model is quantized as it is. The model is resolved when the request is made, so a request naming a model that does not exist in the project, was not produced by fine-tuning, has no base model, or uses an unsupported base model is rejected with 400 rather than accepted and failed later. The request names the model by model_object_id (the deprecated adapter_object_id is still accepted). The run is priced before it is created, and a project that cannot cover it is answered 402.
from together import Together
client = Together()
job = client.post_training.prepare_for_fp4_inference.create(
inputs={
"model_object_id": "ml_abc123",
"model_revision_id": "rv_abc123",
},
)
print(job.id, job.status)curl -X POST "https://api.together.ai/v1/shaping/prepare-for-fp4-inference" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inputs": {
"model_object_id": "ml_abc123",
"model_revision_id": "rv_abc123"
}
}'
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
inputs: {
model_object_id: 'ml_CeG3fF6pyEViU8dE8pk7R',
model_revision_id: 'rv_CeG3faPBj2ABwbAaHPTmx',
calibration_file_id: 'file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35'
}
})
};
fetch('https://api.together.ai/v1/shaping/prepare-for-fp4-inference', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/shaping/prepare-for-fp4-inference",
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([
'inputs' => [
'model_object_id' => 'ml_CeG3fF6pyEViU8dE8pk7R',
'model_revision_id' => 'rv_CeG3faPBj2ABwbAaHPTmx',
'calibration_file_id' => 'file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35'
]
]),
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/shaping/prepare-for-fp4-inference"
payload := strings.NewReader("{\n \"inputs\": {\n \"model_object_id\": \"ml_CeG3fF6pyEViU8dE8pk7R\",\n \"model_revision_id\": \"rv_CeG3faPBj2ABwbAaHPTmx\",\n \"calibration_file_id\": \"file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35\"\n }\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/shaping/prepare-for-fp4-inference")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"inputs\": {\n \"model_object_id\": \"ml_CeG3fF6pyEViU8dE8pk7R\",\n \"model_revision_id\": \"rv_CeG3faPBj2ABwbAaHPTmx\",\n \"calibration_file_id\": \"file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/shaping/prepare-for-fp4-inference")
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 \"inputs\": {\n \"model_object_id\": \"ml_CeG3fF6pyEViU8dE8pk7R\",\n \"model_revision_id\": \"rv_CeG3faPBj2ABwbAaHPTmx\",\n \"calibration_file_id\": \"file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"job_type": "quantization",
"status": "pending",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"user_id": "<string>",
"params": {
"inputs": {
"model_object_id": "ml_CeG3fF6pyEViU8dE8pk7R",
"model_revision_id": "rv_CeG3faPBj2ABwbAaHPTmx",
"calibration_file_id": "file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35"
},
"configuration": {
"user_id": "user_CKfewYkQBpaEmN7wuQS3W",
"model_project_id": "proj_CczF9KYFantA84sNYDTJd",
"model_revision_id": "rv_CeERyXMBQCJTRC1yqGTpk",
"model_name": "ft-qa-artifacts/glm-5.3-e2e-test-adapter",
"base_object_id": "ml_CbJ9yCnij7A47b1xkpioB",
"base_revision_id": "rv_CbJ9yNrws93VQrZum1fTE",
"base_model_name": "zai-org/GLM-5.3-NVFP4"
}
},
"events": [
{
"object": "shaping",
"created_at": "2023-11-07T05:31:56Z",
"level": "Info",
"message": "<string>",
"type": "SHAPING_ERROR",
"hash": "<string>",
"result": {
"model_object_id": "<string>",
"model_revision_id": "<string>"
}
}
],
"results": {
"model_object_id": "<string>",
"model_revision_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
}
}{
"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
Body
Request body for preparing a fine-tuned model for FP4 inference.
Response
Quantization job created successfully.
Quantization job that prepares a fine-tuned model for FP4 inference.
Was this page helpful?
from together import Together
client = Together()
job = client.post_training.prepare_for_fp4_inference.create(
inputs={
"model_object_id": "ml_abc123",
"model_revision_id": "rv_abc123",
},
)
print(job.id, job.status)curl -X POST "https://api.together.ai/v1/shaping/prepare-for-fp4-inference" \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inputs": {
"model_object_id": "ml_abc123",
"model_revision_id": "rv_abc123"
}
}'
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
inputs: {
model_object_id: 'ml_CeG3fF6pyEViU8dE8pk7R',
model_revision_id: 'rv_CeG3faPBj2ABwbAaHPTmx',
calibration_file_id: 'file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35'
}
})
};
fetch('https://api.together.ai/v1/shaping/prepare-for-fp4-inference', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.together.ai/v1/shaping/prepare-for-fp4-inference",
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([
'inputs' => [
'model_object_id' => 'ml_CeG3fF6pyEViU8dE8pk7R',
'model_revision_id' => 'rv_CeG3faPBj2ABwbAaHPTmx',
'calibration_file_id' => 'file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35'
]
]),
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/shaping/prepare-for-fp4-inference"
payload := strings.NewReader("{\n \"inputs\": {\n \"model_object_id\": \"ml_CeG3fF6pyEViU8dE8pk7R\",\n \"model_revision_id\": \"rv_CeG3faPBj2ABwbAaHPTmx\",\n \"calibration_file_id\": \"file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35\"\n }\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/shaping/prepare-for-fp4-inference")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"inputs\": {\n \"model_object_id\": \"ml_CeG3fF6pyEViU8dE8pk7R\",\n \"model_revision_id\": \"rv_CeG3faPBj2ABwbAaHPTmx\",\n \"calibration_file_id\": \"file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.ai/v1/shaping/prepare-for-fp4-inference")
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 \"inputs\": {\n \"model_object_id\": \"ml_CeG3fF6pyEViU8dE8pk7R\",\n \"model_revision_id\": \"rv_CeG3faPBj2ABwbAaHPTmx\",\n \"calibration_file_id\": \"file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"job_type": "quantization",
"status": "pending",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"user_id": "<string>",
"params": {
"inputs": {
"model_object_id": "ml_CeG3fF6pyEViU8dE8pk7R",
"model_revision_id": "rv_CeG3faPBj2ABwbAaHPTmx",
"calibration_file_id": "file-5f1b0c7a-2d19-4a3e-9c60-8ab41c2f7d35"
},
"configuration": {
"user_id": "user_CKfewYkQBpaEmN7wuQS3W",
"model_project_id": "proj_CczF9KYFantA84sNYDTJd",
"model_revision_id": "rv_CeERyXMBQCJTRC1yqGTpk",
"model_name": "ft-qa-artifacts/glm-5.3-e2e-test-adapter",
"base_object_id": "ml_CbJ9yCnij7A47b1xkpioB",
"base_revision_id": "rv_CbJ9yNrws93VQrZum1fTE",
"base_model_name": "zai-org/GLM-5.3-NVFP4"
}
},
"events": [
{
"object": "shaping",
"created_at": "2023-11-07T05:31:56Z",
"level": "Info",
"message": "<string>",
"type": "SHAPING_ERROR",
"hash": "<string>",
"result": {
"model_object_id": "<string>",
"model_revision_id": "<string>"
}
}
],
"results": {
"model_object_id": "<string>",
"model_revision_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
}
}{
"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
}
}