AI configs (beta)

This feature is in beta

To use this feature, pass in a header including the LD-API-Version key with value set to beta. Use this header with each call. To learn more, read Beta resources.

Resources that are in beta are still undergoing testing and development. They may change without notice, including becoming backwards incompatible. The AI configs API allows you to create, retrieve, and edit AI configs, AI config variations, and AI model configurations.

An AI config is a resource in LaunchDarkly that you can use to customize, test, and roll out new large language models (LLMs) within your generative AI applications. Within each AI config, you define one or more AI config variations, each of which includes a model configuration and one or more messages. The model configuration can be a standard one from the list provided by LaunchDarkly, or you can define your own custom AI model configuration.

To learn more, read AI configs.

List AI configs

Get a list of all AI configs in the given project.

Request
path Parameters
projectKey
required
string
Example: default
query Parameters
sort
string

A sort to apply to the list of AI configs.

limit
integer

The number of AI configs to return.

offset
integer

Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query limit.

filter
string

A filter to apply to the list of AI configs.

header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
200

Successful response

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

get/api/v2/projects/{projectKey}/ai-configs
Request samples
Response samples
application/json
{
  • "_links": {
    },
  • "totalCount": 7,
  • "items": [
    ]
}

Create new AI config

Create a new AI config within the given project.

Request
path Parameters
projectKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Request Body schema: application/json
required

AI config object to create

description
string
Default: ""
key
required
string
name
required
string
tags
Array of strings
Responses
201

AI config created

400

Bad request

403

Forbidden

500

Internal server error

post/api/v2/projects/{projectKey}/ai-configs
Request samples
application/json
{
  • "name": "name",
  • "description": "",
  • "key": "key",
  • "tags": [
    ]
}
Response samples
application/json
{
  • "createdAt": 5,
  • "_access": {
    },
  • "_links": {
    },
  • "variations": [
    ],
  • "name": "name",
  • "description": "description",
  • "version": 0,
  • "key": "key",
  • "tags": [
    ],
  • "updatedAt": 2
}

Delete AI config

Delete an existing AI config.

Request
path Parameters
projectKey
required
string
Example: default
configKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
204

No content

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

delete/api/v2/projects/{projectKey}/ai-configs/{configKey}
Request samples
Response samples
application/json
{
  • "code": "code",
  • "message": "message"
}

Get AI config

Retrieve a specific AI config by its key.

Request
path Parameters
projectKey
required
string
configKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
200

AI config found

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

get/api/v2/projects/{projectKey}/ai-configs/{configKey}
Request samples
Response samples
application/json
{
  • "createdAt": 5,
  • "_access": {
    },
  • "_links": {
    },
  • "variations": [
    ],
  • "name": "name",
  • "description": "description",
  • "version": 0,
  • "key": "key",
  • "tags": [
    ],
  • "updatedAt": 2
}

Update AI config

Edit an existing AI config.

The request body must be a JSON object of the fields to update. The values you include replace the existing values for the fields.

Here's an example:

  {
    "description": "Example updated description",
    "tags": ["new-tag"]
  }
Request
path Parameters
projectKey
required
string
configKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Request Body schema: application/json

AI config object to update

description
string
name
string
tags
Array of strings
Responses
200

AI config updated

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

patch/api/v2/projects/{projectKey}/ai-configs/{configKey}
Request samples
application/json
{
  • "name": "name",
  • "description": "description",
  • "tags": [
    ]
}
Response samples
application/json
{
  • "createdAt": 5,
  • "_access": {
    },
  • "_links": {
    },
  • "variations": [
    ],
  • "name": "name",
  • "description": "description",
  • "version": 0,
  • "key": "key",
  • "tags": [
    ],
  • "updatedAt": 2
}

Create AI config variation

Create a new variation for a given AI config.

The model in the request body requires a modelName and parameters, for example:

  "model": {
    "modelName": "claude-3-opus-20240229",
    "parameters": {
      "max_tokens": 1024
    }
  }
Request
path Parameters
projectKey
required
string
configKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Request Body schema: application/json
required

AI config variation object to create

key
required
string
required
Array of objects (Message)
model
required
object
name
required
string
modelConfigKey
string
Responses
201

AI config variation created

400

Bad request

403

Forbidden

500

Internal server error

post/api/v2/projects/{projectKey}/ai-configs/{configKey}/variations
Request samples
application/json
{
  • "name": "name",
  • "messages": [
    ],
  • "model": "{}",
  • "modelConfigKey": "modelConfigKey",
  • "key": "key"
}
Response samples
application/json
{
  • "createdAt": 6,
  • "_links": {
    },
  • "publishedAt": 5,
  • "name": "name",
  • "messages": [
    ],
  • "model": "{}",
  • "modelConfigKey": "modelConfigKey",
  • "version": 1,
  • "key": "key"
}

Delete AI config variation

Delete a specific variation of an AI config by config key and variation key.

Request
path Parameters
projectKey
required
string
configKey
required
string
variationKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
204

No content

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

delete/api/v2/projects/{projectKey}/ai-configs/{configKey}/variations/{variationKey}
Request samples
Response samples
application/json
{
  • "code": "code",
  • "message": "message"
}

Get AI config variation

Get an AI config variation by key. The response includes all variation versions for the given variation key.

Request
path Parameters
projectKey
required
string
Example: default
configKey
required
string
Example: default
variationKey
required
string
Example: default
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
200

Successful response

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

get/api/v2/projects/{projectKey}/ai-configs/{configKey}/variations/{variationKey}
Request samples
Response samples
application/json
{
  • "totalCount": 0,
  • "items": [
    ]
}

Update AI config variation

Edit an existing variation of an AI config. This creates a new version of the variation.

The request body must be a JSON object of the fields to update. The values you include replace the existing values for the fields.

Here's an example:

  {
    "messages": [
      {
        "role": "system",
        "content": "The new message"
      }
    ]
  }
Request
path Parameters
projectKey
required
string
configKey
required
string
variationKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Request Body schema: application/json

AI config variation object to update

Array of objects (Message)
model
object
modelConfigKey
string
name
string
published
boolean
Responses
200

AI config variation updated

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

patch/api/v2/projects/{projectKey}/ai-configs/{configKey}/variations/{variationKey}
Request samples
application/json
{
  • "name": "name",
  • "messages": [
    ],
  • "model": "{}",
  • "published": true,
  • "modelConfigKey": "modelConfigKey"
}
Response samples
application/json
{
  • "createdAt": 6,
  • "_links": {
    },
  • "publishedAt": 5,
  • "name": "name",
  • "messages": [
    ],
  • "model": "{}",
  • "modelConfigKey": "modelConfigKey",
  • "version": 1,
  • "key": "key"
}

Get AI config metrics

Retrieve usage metrics for an AI config by config key.

Request
path Parameters
projectKey
required
string
configKey
required
string
query Parameters
from
required
integer

The starting time, as milliseconds since epoch (inclusive).

to
required
integer

The ending time, as milliseconds since epoch (exclusive). May not be more than 100 days after from.

env
required
string

An environment key. Only metrics from this environment will be included.

header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
200

Metrics computed

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

get/api/v2/projects/{projectKey}/ai-configs/{configKey}/metrics
Request samples
Response samples
application/json
{
  • "generationCount": 5,
  • "generationSuccessCount": 5,
  • "inputTokens": 0,
  • "generationErrorCount": 2,
  • "thumbsDown": 9,
  • "timeToFirstTokenMs": 2,
  • "outputTokens": 6,
  • "totalTokens": 1,
  • "thumbsUp": 7,
  • "durationMs": 3
}

Get AI config metrics by variation

Retrieve usage metrics for an AI config by config key, with results split by variation.

Request
path Parameters
projectKey
required
string
configKey
required
string
query Parameters
from
required
integer

The starting time, as milliseconds since epoch (inclusive).

to
required
integer

The ending time, as milliseconds since epoch (exclusive). May not be more than 100 days after from.

env
required
string

An environment key. Only metrics from this environment will be included.

header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
200

Metrics computed

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

get/api/v2/projects/{projectKey}/ai-configs/{configKey}/metrics-by-variation
Request samples
Response samples
application/json
[
  • {
    }
]

List AI model configs

Get all AI model configs for a project.

Request
path Parameters
projectKey
required
string
Example: default
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
200

Successful response

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

get/api/v2/projects/{projectKey}/ai-configs/model-configs
Request samples
Response samples
application/json
[
  • {
    }
]

Create an AI model config

Create an AI model config. You can use this in any variation for any AI config in your project.

Request
path Parameters
projectKey
required
string
Example: default
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Request Body schema: application/json
required

AI model config object to create

name
required
string

Human readable name of the model

key
required
string

Unique key for the model

id
required
string

Identifier for the model, for use with third party providers

icon
string

Icon for the model

provider
string

Provider for the model

params
object
customParams
object
tags
Array of strings
Responses
200

Successful response

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

post/api/v2/projects/{projectKey}/ai-configs/model-configs
Request samples
application/json
{
  • "provider": "provider",
  • "customParams": "{}",
  • "name": "name",
  • "icon": "icon",
  • "id": "id",
  • "params": "{}",
  • "key": "key",
  • "tags": [
    ]
}
Response samples
application/json
{
  • "_access": {
    },
  • "provider": "provider",
  • "customParams": "{}",
  • "name": "name",
  • "icon": "icon",
  • "global": true,
  • "id": "id",
  • "params": "{}",
  • "version": 0,
  • "key": "key",
  • "tags": [
    ]
}

Delete an AI model config

Delete an AI model config.

Request
path Parameters
projectKey
required
string
Example: default
modelConfigKey
required
string
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
204

No content

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

delete/api/v2/projects/{projectKey}/ai-configs/model-configs/{modelConfigKey}
Request samples
Response samples
application/json
{
  • "code": "code",
  • "message": "message"
}

Get AI model config

Get an AI model config by key.

Request
path Parameters
projectKey
required
string
Example: default
modelConfigKey
required
string
Example: default
header Parameters
LD-API-Version
required
string

Version of the endpoint.

Value: "beta"
Responses
200

Successful response

400

Bad request

403

Forbidden

404

Not found

500

Internal server error

get/api/v2/projects/{projectKey}/ai-configs/model-configs/{modelConfigKey}
Request samples
Response samples
application/json
{
  • "_access": {
    },
  • "provider": "provider",
  • "customParams": "{}",
  • "name": "name",
  • "icon": "icon",
  • "global": true,
  • "id": "id",
  • "params": "{}",
  • "version": 0,
  • "key": "key",
  • "tags": [
    ]
}