Training

The /training endpoint allows you to manage Training Sessions.

Create a Training Session

Endpoint: /training

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Input Parameters

ParameterData TypeDescription
namestringThe name of the Training Session
envstringThe ID of the environment to use for training
modelstringThe ID of the model to use for training

Example Request

{
  "name": "My Training Session",
  "env": "<ENVIRONMENT_ID>",
  "model": "<MODEL_ID>"
}

Example Response

{
  "id": "<SESSION_ID>",
  "project": "<PROJECT_ID>",
  "name": "My Training Session",
  "env": {
    "id": "<ENVIRONMENT_ID>",
    "name": "<ENVIRONMENT_NAME>",
    "provider": "openai"
  },
  "model": "<MODEL_ID>",
  "status": "created",
  "runs": [],
  "dataset": null,
  "job": {},
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-08-22T14:12:34.567Z",
  "updated_at": "2023-08-22T14:12:34.567Z"
}

Code Examples

Create Training Session

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "My Training Session",
  "env": "<ENVIRONMENT_ID>",
  "model": "<MODEL_ID>"
}'

List Training Sessions

Endpoint: /training

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Query Parameters

ParameterData TypeDescription
limitnumberThe maximum number of training sessions to return.
offsetnumberThe number of training sessions to skip.
statusstringThe status of the training sessions to return.

Example Request

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training?limit=10&offset=0&status=created \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

[
  {
    "id": "<SESSION_ID>",
    "project": "<PROJECT_ID>",
    "name": "My Training Session",
    "env": {
      "id": "<ENVIRONMENT_ID>",
      "name": "<ENVIRONMENT_NAME>",
      "provider": "openai"
    },
    "model": "<MODEL_ID>",
    "status": "created",
    "dataset": null,
    "job": {},
    "created_by": "user:<USER_ID>",
    "updated_by": "user:<USER_ID>",
    "created_at": "2023-08-22T14:12:34.567Z",
    "updated_at": "2023-08-22T14:12:34.567Z"
  }
]

Code Examples

List Training Sessions

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training?limit=10&offset=0&status=created \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Retrieve a Training Session

Endpoint: /training/<SESSION_ID>

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Example Request

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID> \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "id": "<SESSION_ID>",
  "project": "<PROJECT_ID>",
  "name": "My Training Session",
  "env": {
    "id": "<ENVIRONMENT_ID>",
    "name": "<ENVIRONMENT_NAME>",
    "provider": "openai"
  },
  "model": "<MODEL_ID>",
  "status": "created",
  "runs": [],
  "dataset": null,
  "job": {},
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-08-22T14:12:34.567Z",
  "updated_at": "2023-08-22T14:12:34.567Z"
}

Code Examples

Retrieve Training Session

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID> \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Add Runs to a Training Session

Endpoint: /training/<SESSION_ID>/add

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Input Parameters

ParameterData TypeDescription
runsstring[]An array of Run IDs to add to the training session

Example Request

{
  "runs": ["<RUN_ID_1>", "<RUN_ID_2>"]
}

Example Response

{
  "ok": true
}

Code Examples

Add Runs to Training Session

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/add \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "runs": ["<RUN_ID_1>", "<RUN_ID_2>"]
}'

List Runs in a Training Session

Endpoint: /training/<SESSION_ID>/runs

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Query Parameters

ParameterData TypeDescription
limitnumberThe maximum number of runs to return.
offsetnumberThe number of runs to skip.

Example Request

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/runs?limit=10&offset=0 \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

[
  {
    "id": "<RUN_ID>",
    "interaction": {
      "id": "<INTERACTION_ID>",
      "name": "<INTERACTION_NAME>",
      "description": "<INTERACTION_DESCRIPTION>",
      "status": "published",
      "version": 1
    },
    "environment": {
      "id": "<ENVIRONMENT_ID>",
      "name": "<ENVIRONMENT_NAME>",
      "provider": "openai"
    },
    "modelId": "<MODEL_ID>",
    "ttl": 3600,
    "status": "completed",
    "token_use": {
      "prompt": 10,
      "completion": 20
    },
    "execution_time": 0.5,
    "created_at": "2023-08-22T14:12:34.567Z",
    "updated_at": "2023-08-22T14:12:34.567Z",
    "account": {
      "id": "<ACCOUNT_ID>",
      "name": "<ACCOUNT_NAME>"
    },
    "project": {
      "id": "<PROJECT_ID>",
      "name": "<PROJECT_NAME>"
    },
    "config": {},
    "source": {
      "type": "api",
      "label": "API Request",
      "principal_type": "user",
      "principal_id": "<USER_ID>",
      "client_ip": "127.0.0.1"
    },
    "created_by": "user:<USER_ID>",
    "updated_by": "user:<USER_ID>"
  }
]

Code Examples

List Runs in Training Session

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/runs?limit=10&offset=0 \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Build Training Data

Endpoint: /training/<SESSION_ID>/build

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Example Request

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/build \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "dataset": "https://storage.googleapis.com/composable-datasets/<DATASET_FILE_NAME>.jsonl"
}

Code Examples

Build Training Data

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/build \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Get Training Data URL

Endpoint: /training/<SESSION_ID>/url

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Example Request

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/url \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "url": "https://storage.googleapis.com/composable-datasets/<DATASET_FILE_NAME>.jsonl"
}

Code Examples

Get Training Data URL

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/url \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Get Training Data Upload URL

Endpoint: /training/<SESSION_ID>/upload-url

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Query Parameters

ParameterData TypeDescription
resumablebooleanWhether the upload should be resumable.

Example Request

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/upload-url?resumable=true \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "url": "https://storage.googleapis.com/upload/storage/v1/b/composable-datasets/o?uploadType=resumable&upload_id=<UPLOAD_ID>"
}

Code Examples

Get Training Data Upload URL

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/upload-url?resumable=true \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Start Training

Endpoint: /training/<SESSION_ID>/start

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Example Request

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/start \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "id": "<JOB_ID>",
  "status": "pending",
  "created_at": "2023-08-22T14:12:34.567Z",
  "updated_at": "2023-08-22T14:12:34.567Z"
}

Code Examples

Start Training

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/start \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Cancel Training

Endpoint: /training/<SESSION_ID>/cancel

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Example Request

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/cancel \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "id": "<JOB_ID>",
  "status": "cancelled",
  "created_at": "2023-08-22T14:12:34.567Z",
  "updated_at": "2023-08-22T14:12:34.567Z"
}

Code Examples

Cancel Training

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/cancel \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Get Training Job

Endpoint: /training/job/<JOB_ID>

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<JOB_ID>The ID of the training job.

Query Parameters

ParameterData TypeDescription
syncbooleanWhether to wait for the job to complete before returning.

Example Request

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/job/<JOB_ID>?sync=true \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "id": "<JOB_ID>",
  "status": "completed",
  "created_at": "2023-08-22T14:12:34.567Z",
  "updated_at": "2023-08-22T14:12:34.567Z"
}

Code Examples

Get Training Job

curl -X GET \
  https://studio-server-production.api.becomposable.com/api/v1/training/job/<JOB_ID>?sync=true \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Set Training Dataset

Endpoint: /training/<SESSION_ID>/dataset

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<SESSION_ID>The ID of the training session.

Input Parameters

ParameterData TypeDescription
datasetstringThe name of the dataset to use. If default is specified, the dataset generated by the /build endpoint will be used.

Example Request

{
  "dataset": "default"
}

Example Response

{
  "dataset": "https://storage.googleapis.com/composable-datasets/<DATASET_FILE_NAME>.jsonl"
}

Code Examples

Set Training Dataset

curl -X POST \
  https://studio-server-production.api.becomposable.com/api/v1/training/<SESSION_ID>/dataset \
  -H 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "dataset": "default"
}'

Was this page helpful?