Upload a file
- REST API
- OpenAI Python
Create a fine-tuning job
- REST API
- OpenAI Python
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Fine-tune your models with Azure OpenAI
curl -X POST --header 'Authorization: Bearer <portkey_api_key>' \
--header 'x-portkey-provider: @provider' \
--form 'file=@dataset.jsonl' \
--form 'purpose=fine-tune' \
'https://aigw.portkey.ai/v1/files'
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="PORTKEY_API_KEY",
api_version="2023-05-15",
azure_endpoint="https://aigw.portkey.ai/v1",
default_headers={"x-portkey-provider": "@PROVIDER"}
)
# Upload a file for fine-tuning
file = client.files.create(
file=open("dataset.jsonl", "rb"),
purpose="fine-tune"
)
print(file)
curl -X POST --header 'Content-Type: application/json' \
--header 'Authorization: Bearer <portkey_api_key>' \
--data \
$'{"model": "@provider/<base_model>", "suffix": "<finetune_name>", "training_file": "<file_id>", "validation_file": "<file_id>", "hyperparameters": {"n_epochs": 1}}\n' \
'https://aigw.portkey.ai/v1/fine_tuning/jobs'
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="PORTKEY_API_KEY",
api_version="2023-05-15",
azure_endpoint="https://aigw.portkey.ai/v1"
)
# Create a fine-tuning job
fine_tune_job = client.fine_tuning.jobs.create(
model="@PROVIDER/gpt-35-turbo", # Base model to fine-tune
training_file="file_id", # ID of the uploaded training file
validation_file="file_id", # Optional: ID of the uploaded validation file
suffix="finetune_name", # Custom suffix for the fine-tuned model name
hyperparameters={
"n_epochs": 1
}
)
print(fine_tune_job)
Was this page helpful?
