---
title: "Submit Training Job"
method: POST
path: "/agents/{agent_id}/tune"
tags: ["/agents/{id}/tune"]
---

# Submit Training Job

`POST /agents/{agent_id}/tune`

Create a tuning job for the specified `Agent` to specialize it to your specific domain or use case.

This API initiates an asynchronous tuning task. You can provide the required data through one of two ways:

- Provide a `training_file` and an optional `test_file`. If no `test_file` is provided, a portion of the `training_file` will be held out as the test set. For easy reusability, the `training_file` is automatically saved as a `Tuning` `Dataset`, and the `test_file` as an `Evaluation` `Dataset`. You can manage them via the `/datasets/tune` and `/datasets/evaluation` endpoints.

- Provide a `Tuning` `Dataset` and an optional `Evaluation` `Dataset`. You can create a `Tuning` `Dataset` and `Evaluation` `Dataset` using the `/datasets/tune` and `/datasets/evaluation` endpoints respectively.

The API returns a tune job `id` which can be used to check on the status of your tuning task through the `GET /tune/jobs/{job_id}/metadata` endpoint.

After the tuning job is complete, the metadata associated with the tune job will include evaluation results and a model ID. You can then deploy the tuned model to the agent by editing its config with the tuned model ID and the "Edit Agent" API (i.e. the `PUT /agents/{agent_id}` API). To deactivate the tuned model, you will need to edit the Agent's config again and set the `llm_model_id` field to "default". For an end-to-end walkthrough, see the `Tune & Evaluation Guide`.

## Path parameters

- `agent_id` string, uuid, required — ID of the Agent to list tuning jobs for

## Response `200`

Successful Response

- TuneResponse — Response to POST /applications/{application_id}/tune request
  - `id` string, uuid, required — ID of the created tune job

## Other responses

- `422` — Validation Error

## Changes

- **2025-05-08** `17bdb8a33fb4` — 9 info
  - added the new optional request property `hyperparams[learning_rate]`
  - added the new optional request property `hyperparams[lora_alpha]`
  - added the new optional request property `hyperparams[lora_dropout]`
  - added the new optional request property `hyperparams[lora_rank]`
  - …5 more
- **2025-02-26** `5298551c424b` — 1 warning, 7 info
  - removed the request property `model_id`
  - api operation id `create_tune_job_agents__agent_id__tune_post` removed and replaced with `submit_training_job_agents__agent_id__tune_post`
  - added the new optional request property `test_dataset_name`
  - added the new optional request property `train_dataset_name`
  - …4 more
- **2025-01-14** `4dd01a1cc34b` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/contextualai/apis/endpoints/changes/agents/:agent_id/tune/post.md)

---

[API](https://skmtc.dev/contextualai/apis/endpoints.md) · [All operations](https://skmtc.dev/contextualai/apis/endpoints/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/contextualai/endpoints/revisions/17bdb8a33fb4/schema)
