# List AI Configs

GET https://app.launchdarkly.com/api/v2/projects/{projectKey}/ai-configs

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

Reference: https://launchdarkly.com/docs/api/ai-configs/get-ai-configs

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/ai-configs:
    get:
      operationId: get-ai-configs
      summary: List AI Configs
      description: Get a list of all AI Configs in the given project.
      tags:
        - subpackage_aiConfigs
      parameters:
        - name: projectKey
          in: path
          required: true
          schema:
            type: string
        - name: sort
          in: query
          description: A sort to apply to the list of AI Configs.
          required: false
          schema:
            type: string
        - name: limit
          in: query
          description: The number of resources to return.
          required: false
          schema:
            type: integer
        - name: offset
          in: query
          description: >-
            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`.
          required: false
          schema:
            type: integer
        - name: filter
          in: query
          description: A filter to apply to the list.
          required: false
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIConfigs'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    AiConfigsLink:
      type: object
      properties:
        href:
          type: string
        type:
          type: string
      title: AiConfigsLink
    PaginatedLinks:
      type: object
      properties:
        first:
          $ref: '#/components/schemas/AiConfigsLink'
        last:
          $ref: '#/components/schemas/AiConfigsLink'
        next:
          $ref: '#/components/schemas/AiConfigsLink'
        prev:
          $ref: '#/components/schemas/AiConfigsLink'
        self:
          $ref: '#/components/schemas/AiConfigsLink'
      required:
        - self
      title: PaginatedLinks
    ActionSpecifier:
      type: string
      title: ActionSpecifier
    AiConfigsAccessDeniedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AiConfigsAccessDeniedReasonEffect
    AiConfigsAccessDeniedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AiConfigsAccessDeniedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AiConfigsAccessDeniedReason
    AiConfigsAccessDenied:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/AiConfigsAccessDeniedReason'
      required:
        - action
        - reason
      title: AiConfigsAccessDenied
    AiConfigsAccessAllowedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AiConfigsAccessAllowedReasonEffect
    AiConfigsAccessAllowedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AiConfigsAccessAllowedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AiConfigsAccessAllowedReason
    AiConfigsAccessAllowedRep:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/AiConfigsAccessAllowedReason'
      required:
        - action
        - reason
      title: AiConfigsAccessAllowedRep
    AiConfigsAccess:
      type: object
      properties:
        denied:
          type: array
          items:
            $ref: '#/components/schemas/AiConfigsAccessDenied'
        allowed:
          type: array
          items:
            $ref: '#/components/schemas/AiConfigsAccessAllowedRep'
      required:
        - denied
        - allowed
      title: AiConfigsAccess
    CoreLink:
      type: object
      properties:
        href:
          type: string
        type:
          type: string
      required:
        - href
        - type
      title: CoreLink
    ParentAndSelfLinks:
      type: object
      properties:
        self:
          $ref: '#/components/schemas/CoreLink'
        parent:
          $ref: '#/components/schemas/CoreLink'
      required:
        - self
        - parent
      description: The location and content type of related resources
      title: ParentAndSelfLinks
    MaintainerMember:
      type: object
      properties:
        _id:
          type: string
        email:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        role:
          type: string
      required:
        - _id
        - email
        - role
      title: MaintainerMember
    AiConfigsMaintainerTeam:
      type: object
      properties:
        key:
          type: string
        name:
          type: string
      required:
        - key
        - name
      title: AiConfigsMaintainerTeam
    AIConfig__maintainer:
      oneOf:
        - $ref: '#/components/schemas/MaintainerMember'
        - $ref: '#/components/schemas/AiConfigsMaintainerTeam'
      title: AIConfig__maintainer
    AiConfigMode:
      type: string
      enum:
        - agent
        - completion
        - judge
      default: completion
      title: AiConfigMode
    ParentLink:
      type: object
      properties:
        parent:
          $ref: '#/components/schemas/CoreLink'
      required:
        - parent
      title: ParentLink
    Message:
      type: object
      properties:
        content:
          type: string
        role:
          type: string
      required:
        - content
        - role
      title: Message
    AiConfigVariationModel:
      type: object
      properties: {}
      title: AiConfigVariationModel
    VariationTool:
      type: object
      properties:
        key:
          type: string
          description: The key of the tool to use.
        version:
          type: integer
          description: The version of the tool.
        customParameters:
          type: object
          additionalProperties:
            description: Any type
          description: Custom metadata and configuration for application-level use
      required:
        - key
        - version
      title: VariationTool
    JudgeAttachment:
      type: object
      properties:
        judgeConfigKey:
          type: string
          description: Key of the judge AI Config
        samplingRate:
          type: number
          format: double
          description: Sampling rate for this judge attachment (0.0 to 1.0)
      required:
        - judgeConfigKey
        - samplingRate
      title: JudgeAttachment
    JudgeConfiguration:
      type: object
      properties:
        judges:
          type: array
          items:
            $ref: '#/components/schemas/JudgeAttachment'
          description: >
            List of judges for this variation. When updating, this replaces all
            existing judge attachments, and if empty, removes all judge
            attachments.
      title: JudgeConfiguration
    AIConfigVariation:
      type: object
      properties:
        _links:
          $ref: '#/components/schemas/ParentLink'
        color:
          type: string
        comment:
          type: string
        description:
          type: string
          description: >-
            Returns the description for the agent. This is only returned for
            agent variations.
        instructions:
          type: string
          description: >-
            Returns the instructions for the agent. This is only returned for
            agent variations.
        key:
          type: string
        _id:
          type: string
        messages:
          type: array
          items:
            $ref: '#/components/schemas/Message'
        model:
          $ref: '#/components/schemas/AiConfigVariationModel'
        modelConfigKey:
          type: string
        name:
          type: string
        createdAt:
          type: integer
          format: int64
        version:
          type: integer
        state:
          type: string
        _archivedAt:
          type: integer
          format: int64
        _publishedAt:
          type: integer
          format: int64
        tools:
          type: array
          items:
            $ref: '#/components/schemas/VariationTool'
        judgeConfiguration:
          $ref: '#/components/schemas/JudgeConfiguration'
        judgingConfigKeys:
          type: array
          items:
            type: string
      required:
        - key
        - _id
        - model
        - name
        - createdAt
        - version
      title: AIConfigVariation
    AiConfigDependencyType:
      type: string
      enum:
        - agent-graph
      description: The type of the dependent resource
      title: AiConfigDependencyType
    AIConfigDependency:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/AiConfigDependencyType'
          description: The type of the dependent resource
        key:
          type: string
          description: The key of the dependent resource
      required:
        - type
        - key
      description: A resource that depends on this AI Config
      title: AIConfigDependency
    AIConfig:
      type: object
      properties:
        _access:
          $ref: '#/components/schemas/AiConfigsAccess'
        _links:
          $ref: '#/components/schemas/ParentAndSelfLinks'
        description:
          type: string
        key:
          type: string
        _maintainer:
          $ref: '#/components/schemas/AIConfig__maintainer'
        mode:
          $ref: '#/components/schemas/AiConfigMode'
        name:
          type: string
        tags:
          type: array
          items:
            type: string
        version:
          type: integer
        variations:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigVariation'
        createdAt:
          type: integer
          format: int64
        updatedAt:
          type: integer
          format: int64
        evaluationMetricKey:
          type: string
          description: Evaluation metric key for this AI Config
        evaluationMetricKeys:
          type: array
          items:
            type: string
          description: List of evaluation metric keys for this AI Config
        isInverted:
          type: boolean
          description: >-
            Whether the evaluation metric is inverted, meaning a lower value is
            better if set as true
        dependencies:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigDependency'
          description: Resources that depend on this AI Config, grouped by type
      required:
        - description
        - key
        - name
        - tags
        - version
        - variations
        - createdAt
        - updatedAt
      title: AIConfig
    AIConfigs:
      type: object
      properties:
        _links:
          $ref: '#/components/schemas/PaginatedLinks'
        items:
          type: array
          items:
            $ref: '#/components/schemas/AIConfig'
        totalCount:
          type: integer
      required:
        - items
        - totalCount
      title: AIConfigs
    Error:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
      required:
        - message
        - code
      title: Error
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/projects/default/ai-configs"

headers = {"Authorization": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/projects/default/ai-configs';
const options = {method: 'GET', headers: {Authorization: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/projects/default/ai-configs"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/projects/default/ai-configs")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/projects/default/ai-configs")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.launchdarkly.com/api/v2/projects/default/ai-configs', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/projects/default/ai-configs");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/projects/default/ai-configs")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```