Skip to main content
The Fine-tuning API proxies fine-tuning job management to the configured provider. All endpoints follow the OpenAI fine-tuning API contract. The correct operation is determined automatically by the HTTP method and the presence of a :jobId path parameter.
Fine-tuning requires uploading a training file first. Use POST /v1/files with purpose=fine-tune to prepare your data.

Endpoint routing

All fine-tuning requests are handled at /v1/fine_tuning/jobs/:jobId?/:cancel?. The gateway dispatches to the correct operation based on the method and path:
MethodPathOperation
GET/v1/fine_tuning/jobsList fine-tuning jobs
POST/v1/fine_tuning/jobsCreate a fine-tuning job
GET/v1/fine_tuning/jobs/:idRetrieve a fine-tuning job
POST/v1/fine_tuning/jobs/:id/cancelCancel a fine-tuning job

List fine-tuning jobs

GET /v1/fine_tuning/jobs Returns a list of fine-tuning jobs for the configured provider.

Request

x-portkey-provider
string
required
The provider to route the request to.
x-portkey-api-key
string
required
Your Portkey API key or provider API key.
limit
number
default:"20"
Maximum number of jobs to return.
after
string
Cursor for pagination. Pass the id of the last job from the previous page.

Response

object
string
Always list.
data
array
Array of fine-tuning job objects.
has_more
boolean
Whether additional jobs are available.
curl https://your-gateway.example.com/v1/fine_tuning/jobs \
  -H "x-portkey-api-key: YOUR_API_KEY" \
  -H "x-portkey-provider: openai"

Create a fine-tuning job

POST /v1/fine_tuning/jobs Creates a new fine-tuning job. The request body is forwarded directly to the provider.

Request

x-portkey-provider
string
required
The provider to route the request to.
x-portkey-api-key
string
required
Your Portkey API key or provider API key.
training_file
string
required
The ID of the uploaded training file (must have purpose=fine-tune).
model
string
required
The base model to fine-tune. For example, gpt-4o-mini-2024-07-18.
validation_file
string
The ID of an optional validation file.
hyperparameters
object
suffix
string
A string of up to 18 characters appended to the fine-tuned model name.
metadata
object
Optional key-value metadata to attach to the job.

Response

id
string
Unique identifier for the fine-tuning job.
object
string
Always fine_tuning.job.
model
string
The base model being fine-tuned.
fine_tuned_model
string
The name of the fine-tuned model once training completes. null while in progress.
status
string
Current job status. Values: validating_files, queued, running, succeeded, failed, cancelled.
created_at
number
Unix timestamp when the job was created.
trained_tokens
number
Number of tokens used in training, or null if not yet available.
curl https://your-gateway.example.com/v1/fine_tuning/jobs \
  -X POST \
  -H "Content-Type: application/json" \
  -H "x-portkey-api-key: YOUR_API_KEY" \
  -H "x-portkey-provider: openai" \
  -d '{
    "training_file": "file-abc123",
    "model": "gpt-4o-mini-2024-07-18"
  }'

Retrieve a fine-tuning job

GET /v1/fine_tuning/jobs/:id Retrieves details for a specific fine-tuning job. Use this to poll the status of an in-progress job.

Request

id
string
required
The ID of the fine-tuning job to retrieve.
x-portkey-provider
string
required
The provider to route the request to.
x-portkey-api-key
string
required
Your Portkey API key or provider API key.

Response

Returns a single fine-tuning job object. See Create a fine-tuning job for the full field list.
curl https://your-gateway.example.com/v1/fine_tuning/jobs/ftjob-abc123 \
  -H "x-portkey-api-key: YOUR_API_KEY" \
  -H "x-portkey-provider: openai"

Cancel a fine-tuning job

POST /v1/fine_tuning/jobs/:id/cancel Cancels a fine-tuning job that is queued or running.
Once a job is cancelled it cannot be resumed. Any compute costs incurred up to the cancellation point may still apply.

Request

id
string
required
The ID of the fine-tuning job to cancel.
x-portkey-provider
string
required
The provider to route the request to.
x-portkey-api-key
string
required
Your Portkey API key or provider API key.

Response

Returns the updated fine-tuning job object with status: cancelled.
curl https://your-gateway.example.com/v1/fine_tuning/jobs/ftjob-abc123/cancel \
  -X POST \
  -H "x-portkey-api-key: YOUR_API_KEY" \
  -H "x-portkey-provider: openai"

Build docs developers (and LLMs) love