> For the complete documentation index, see [llms.txt](https://docs.flashback.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flashback.tech/support-reference/platform-api-reference/ai-apis/ai-llms/post_ai_llm.md).

# post\_\_ai\_llm

{% hint style="info" %}
This API endpoint is currently available only in the TEST environment. It is not yet available in production.
{% endhint %}

`POST /ai/llm`

*Create AI LLM Configuration*

Create a new AI/LLM provider configuration for your workspace. This endpoint allows you to configure connections to various AI and Large Language Model providers.

**Supported AI Providers:**

* `OPENAI`: OpenAI (GPT-4, GPT-3.5, etc.)
* `GOOGLE`: Google AI (Gemini, PaLM, etc.)
* `ANTHROPIC`: Anthropic (Claude models)
* `AWS`: Amazon Bedrock and AWS AI services
* `OTHER`: Custom or other AI providers

**Key Features:**

* Centralized AI provider credential management
* Support for multiple AI providers per workspace
* Encrypted storage of API keys and secrets
* Integration with Flashgate repositories for AI-powered features

**Security:**

* API keys and secrets are encrypted before storage
* Credentials are never returned in API responses (only masked values)
* Workspace-level access controls apply

**Validation:**

* Configuration name must be unique within your workspace
* Endpoint URL format is validated
* Credentials can be validated after creation using the validate endpoint

#### TypeScript Client Library

```typescript
public createAiLlm = async (data: CreateAiLlmRequest): Promise<CreateAiLlmResponse> => {
  return this.makeRequest<CreateAiLlmResponse>('ai/llm', 'POST', data);
};
```

#### Code Samples

{% tabs %}
{% tab title="Shell" %}

```shell
# You can also use wget
curl -X POST https://backend.flashback.tech/ai/llm \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
POST https://backend.flashback.tech/ai/llm HTTP/1.1
Host: backend.flashback.tech
Content-Type: application/json
Accept: application/json
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const inputBody = '{
  "name": "My OpenAI Config",
  "aiType": "OPENAI",
  "endpoint": "https://api.openai.com/v1",
  "secret": "sk-proj-xxxxxxxxxxxx",
  "workspaceId": "workspace-123"
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

fetch('https://backend.flashback.tech/ai/llm',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'
require 'json'

headers = {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}'
}

result = RestClient.post 'https://backend.flashback.tech/ai/llm',
  params: {
  }, headers: headers

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}

r = requests.post('https://backend.flashback.tech/ai/llm', headers = headers)

print(r.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

require 'vendor/autoload.php';

$headers = array(
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
    $response = $client->request('POST','https://backend.flashback.tech/ai/llm', array(
        'headers' => $headers,
        'json' => $request_body,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }

 // ...
```

{% endtab %}

{% tab title="Java" %}

```java
URL obj = new URL("https://backend.flashback.tech/ai/llm");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
       "bytes"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
    }

    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "https://backend.flashback.tech/ai/llm", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
```

{% endtab %}
{% endtabs %}

> Body parameter

```json
{
  "name": "My OpenAI Config",
  "aiType": "OPENAI",
  "endpoint": "https://api.openai.com/v1",
  "key": "optional-access-key",
  "secret": "sk-proj-xxxxxxxxxxxx",
  "workspaceId": "workspace-123"
}
```

#### Parameters <a href="#post__ai_llm-parameters" id="post__ai_llm-parameters"></a>

| Name          | In   | Type   | Required | Description                                          |
| ------------- | ---- | ------ | -------- | ---------------------------------------------------- |
| body          | body | object | true     | none                                                 |
| » name        | body | string | true     | Human-readable name for the AI LLM configuration     |
| » aiType      | body | string | true     | Type of AI provider                                  |
| » endpoint    | body | string | true     | API endpoint URL for the AI provider                 |
| » key         | body | string | false    | Access key or API key (optional, provider-dependent) |
| » secret      | body | string | true     | Secret key or API secret for authentication          |
| » workspaceId | body | string | true     | Workspace ID this configuration belongs to           |

**Enumerated Values**

| Parameter | Value     |
| --------- | --------- |
| » aiType  | OPENAI    |
| » aiType  | GOOGLE    |
| » aiType  | ANTHROPIC |
| » aiType  | AWS       |
| » aiType  | OTHER     |

> Example responses

> 200 Response

```json
{
  "success": true,
  "aiLlmId": "550e8400-e29b-41d4-a716-446655440000",
  "message": "AI LLM configuration created successfully"
}
```

#### Responses <a href="#post__ai_llm-responses" id="post__ai_llm-responses"></a>

| Status | Meaning                                                                    | Description                               | Schema |
| ------ | -------------------------------------------------------------------------- | ----------------------------------------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)                    | AI LLM configuration created successfully | Inline |
| 400    | [Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)           | Validation error or invalid parameters    | Inline |
| 403    | [Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)             | Insufficient permissions                  | Inline |
| 500    | [Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) | Failed to create configuration            | Inline |

#### Response Schema <a href="#post__ai_llm-responseschema" id="post__ai_llm-responseschema"></a>

Status Code **200**

| Name      | Type    | Required | Restrictions | Description                                     |
| --------- | ------- | -------- | ------------ | ----------------------------------------------- |
| » success | boolean | false    | none         | Operation success status                        |
| » aiLlmId | string  | false    | none         | Unique identifier for the created AI LLM config |
| » message | string  | false    | none         | Success message                                 |

Status Code **400**

| Name      | Type    | Required | Restrictions | Description |
| --------- | ------- | -------- | ------------ | ----------- |
| » success | boolean | false    | none         | none        |
| » message | string  | false    | none         | none        |

Status Code **403**

| Name      | Type    | Required | Restrictions | Description |
| --------- | ------- | -------- | ------------ | ----------- |
| » success | boolean | false    | none         | none        |
| » message | string  | false    | none         | none        |

Status Code **500**

| Name      | Type    | Required | Restrictions | Description |
| --------- | ------- | -------- | ------------ | ----------- |
| » success | boolean | false    | none         | none        |
| » message | string  | false    | none         | none        |

To perform this operation, you must be authenticated by means of one of the following methods: BearerAuth


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flashback.tech/support-reference/platform-api-reference/ai-apis/ai-llms/post_ai_llm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
