# Get AI Config variation

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

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

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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/ai-configs/{configKey}/variations/{variationKey}:
    get:
      operationId: get-ai-config-variation
      summary: Get AI Config variation
      description: >-
        Get an AI Config variation by key. The response includes all variation
        versions for the given variation key.
      tags:
        - subpackage_aiConfigs
      parameters:
        - name: projectKey
          in: path
          required: true
          schema:
            type: string
        - name: configKey
          in: path
          required: true
          schema:
            type: string
        - name: variationKey
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIConfigVariationsResponse'
        '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:
    CoreLink:
      type: object
      properties:
        href:
          type: string
        type:
          type: string
      required:
        - href
        - type
      title: CoreLink
    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
    AIConfigVariationsResponse:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigVariation'
        totalCount:
          type: integer
      required:
        - items
        - totalCount
      title: AIConfigVariationsResponse
    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/default/variations/default"

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/default/variations/default';
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/default/variations/default"

	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/default/variations/default")

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/default/variations/default")
  .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/default/variations/default', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/projects/default/ai-configs/default/variations/default");
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/default/variations/default")! 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()
```