Create AI Connection
(v2)POST
Registers your LLM application with Confident AI and returns the id of the connection. The endpoint is called once as the connection is created to work out whether it is active, which you read back by retrieving the connection or pinging it. Requires the Starter plan or above.
curl -X POST "https://api.confident-ai.com/v2/ai-connections" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "Production Chatbot",
"type": "ENDPOINT",
"endpoint": "https://api.example.com/chat",
"responseMode": "HTTP_RESPONSE",
"asyncResponse": false,
"timeout": 60,
"maxConcurrency": 5,
"maxRetries": 3,
"defaultNumGenerations": 1,
"headers": [
{
"key": "Authorization",
"value": "Bearer YOUR-TOKEN"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"queryParams": [
{
"key": "stream",
"value": "false"
}
],
"payload": {
"query": "{{input}}"
},
"hyperparameters": {
"model": "gpt-4o",
"temperature": 0.2
},
"authentication": {
"authType": "HMAC",
"hmacConfig": {
"headerKey": "X-Signature",
"signaturePrefix": "sha256=",
"secret": "YOUR-SIGNING-SECRET"
}
},
"cloudProvider": {
"enabled": true,
"provider": "AZURE_KEY_VAULT",
"vaultUrl": "https://acme-vault.vault.azure.net/",
"azureCredentials": {
"tenantId": "YOUR-TENANT-ID",
"clientId": "YOUR-CLIENT-ID",
"clientSecret": "YOUR-CLIENT-SECRET"
}
},
"actualOutputKeyPath": [
"choices",
0,
"message",
"content"
],
"retrievalContextKeyPath": [
"retrieval",
"documents"
],
"toolsCalledKeyPath": [
"tool_calls"
],
"stateKeyPath": [
"session",
"state"
],
"inputTokenCountKeyPath": [
"usage",
"prompt_tokens"
],
"outputTokenCountKeyPath": [
"usage",
"completion_tokens"
],
"tokenCostKeyPath": [
"usage",
"cost"
],
"actualOutputEvent": "token",
"retrievalContextEvent": "retrieval",
"toolsCalledEvent": "tool_call",
"stateEvent": "state",
"actualOutputAccumulate": true,
"actualOutputTransformerId": "<TRANSFORMER-ID>",
"retrievalContextTransformerId": "<TRANSFORMER-ID>",
"toolsCalledTransformerId": "<TRANSFORMER-ID>",
"stateTransformerId": "<TRANSFORMER-ID>",
"inputTokenCountTransformerId": "<TRANSFORMER-ID>",
"outputTokenCountTransformerId": "<TRANSFORMER-ID>",
"tokenCostTransformerId": "<TRANSFORMER-ID>",
"prompts": {
"systemPrompt": {
"alias": "customer-support",
"label": "production"
}
}
}'{
"success": true,
"data": {
"id": "<AI-CONNECTION-ID>"
},
"link": "https://app.confident-ai.com/project/<PROJECT-ID>/ai-connections/<AI-CONNECTION-ID>",
"deprecated": false
}Headers
CONFIDENT_API_KEYstringRequiredThe API key of your Confident AI project.
Request body
namestringRequiredThe name of the AI connection, unique within the project.
typeenumHow Confident AI reaches your LLM application:
ENDPOINTcalls theendpointyou registered,RELAY_ENDPOINTcalls it through the Confident AI relay so it never leaves your network boundary, andAGENT_HANDLERexpects your own runner to pull work rather than being called, so it needs no endpoint. Defaults toENDPOINT.Show 3 enum valuesHide 3 enum values
ENDPOINTRELAY_ENDPOINTAGENT_HANDLER
endpointstring | nullThe
https://URL Confident AI calls to reach your LLM application, or awss://URL whenresponseModeisWEBSOCKET. AnAGENT_HANDLERconnection needs none. Sendnullto clear it.responseModeenum | nullHow your application replies.
HTTP_RESPONSEreturns one completed body.SSE_STREAMING,HTTP_STREAMINGandWEBSOCKETstream the answer, so the values are read from named events as they arrive rather than out of a finished body, andWEBSOCKETrequires awss://endpoint.PHONEandSIPare voice connections placed over a telephony provider.Show 7 enum valuesHide 7 enum values
HTTP_RESPONSESSE_STREAMINGHTTP_STREAMINGWEBSOCKETPHONESIPWEBRTC
asyncResponsebooleanWhether your application acknowledges the request and posts the result back later instead of answering inline. Only a non-streaming
responseModesupports this.timeoutinteger | nullHow many seconds to wait for your application to answer before giving up on a request. Defaults to 60 when the connection is created. Send
nullto clear it.maxConcurrencyinteger | nullThe most requests Confident AI sends to your application at the same time. Send
nullto leave it unbounded.maxRetriesinteger | nullHow many times a failed request is retried before the test case is recorded as errored. Send
nullto clear it.defaultNumGenerationsintegerHow many times your application is called per test case, so one unlucky output does not decide the result. At most 50.
headersarray | nullThe headers sent with every request. The list replaces the stored headers rather than merging into them, so include every header the connection should keep. Send
nullto clear them.Show 2 propertiesHide 2 properties
keystringRequiredThe header or query parameter name.
valuestringRequiredThe value sent under this name on every request. It is stored as sent and read back as stored.
queryParamsarray | nullThe query parameters appended to every request. The list replaces the stored parameters rather than merging into them. Send
nullto clear them.Show 2 propertiesHide 2 properties
keystringRequiredThe header or query parameter name.
valuestringRequiredThe value sent under this name on every request. It is stored as sent and read back as stored.
payloadobject | nullThe request body template Confident AI sends. Placeholders such as
{{input}}are filled from the test case, and any key inpromptsis filled with that prompt's text. Sendnullto clear it.hyperparametersobject | nullFree-form settings recorded against every test run made through this connection, so results can be compared across configurations. They are not sent to your application. Send
nullto clear them.authenticationobject | nullThe authentication configuration Confident AI applies when calling your application. Set
authTypetoAUTH0,HMAC,AZURE_AD,OAUTH2_CLIENT_CREDENTIALSorLIVEKITand put that scheme's settings in the matching object:auth0Config,hmacConfig,azureAdConfig,oauth2ConfigorlivekitConfig. A value that does not match that shape is rejected. Sendnullto clear it.cloudProviderobject | nullThe cloud vault configuration Confident AI uses to pull credentials at call time instead of holding them itself. Set
enabled,providertoAZURE_KEY_VAULT,vaultUrlto your vault, andazureCredentialswith thetenantId,clientIdandclientSecretused to read from it. A value that does not match that shape is rejected. Sendnullto clear it.actualOutputKeyPatharray | nullWhere your application's answer sits in its response. Each element is an object key or an array index, walked in order, so
["choices", 0, "message", "content"]readschoices[0].message.content. A connection needs this oractualOutputTransformerIdbefore it can be used. Sendnullor an empty list to clear it.Show 2 variantsHide 2 variants
string
- OR
integer
retrievalContextKeyPatharray | nullWhere the retrieved context sits in your application's response, walked the same way as
actualOutputKeyPath. Set it for RAG applications so retrieval metrics have something to score. Sendnullor an empty list to clear it.Show 2 variantsHide 2 variants
string
- OR
integer
toolsCalledKeyPatharray | nullWhere the list of tools your application called sits in its response, walked the same way as
actualOutputKeyPath. Set it for agents so tool-use metrics have something to score. Sendnullor an empty list to clear it.Show 2 variantsHide 2 variants
string
- OR
integer
stateKeyPatharray | nullWhere the conversation state sits in your application's response, walked the same way as
actualOutputKeyPath. Confident AI reads it after each simulated turn and sends it back on the next one. Sendnullor an empty list to clear it.Show 2 variantsHide 2 variants
string
- OR
integer
inputTokenCountKeyPatharray | nullWhere the prompt token count sits in your application's response, walked the same way as
actualOutputKeyPath. Sendnullor an empty list to clear it.Show 2 variantsHide 2 variants
string
- OR
integer
outputTokenCountKeyPatharray | nullWhere the completion token count sits in your application's response, walked the same way as
actualOutputKeyPath. Sendnullor an empty list to clear it.Show 2 variantsHide 2 variants
string
- OR
integer
tokenCostKeyPatharray | nullWhere the cost of the call sits in your application's response, walked the same way as
actualOutputKeyPath. Sendnullor an empty list to clear it.Show 2 variantsHide 2 variants
string
- OR
integer
actualOutputEventstring | nullFor a streaming
responseMode, the name of the event carrying your application's answer. Confident AI reads the value out of the events with this name instead of out of a completed body, applyingactualOutputKeyPathto each one. Sendnullto clear it.retrievalContextEventstring | nullFor a streaming
responseMode, the name of the event carrying the retrieved context, read the same way asactualOutputEvent. Sendnullto clear it.toolsCalledEventstring | nullFor a streaming
responseMode, the name of the event carrying the tools called, read the same way asactualOutputEvent. Sendnullto clear it.stateEventstring | nullFor a streaming
responseMode, the name of the event carrying the conversation state, read the same way asactualOutputEvent. Sendnullto clear it.actualOutputAccumulatebooleanFor a streaming
responseMode, whether the chunks arriving onactualOutputEventare joined into one answer. Set it tofalsewhen each event already carries the whole answer and only the last one counts.actualOutputTransformerIdstring | nullThe id of a transformer that extracts the answer by running your code over the response, for shapes a key path cannot reach. Send this or
actualOutputKeyPath, never both. The transformer must belong to this project. Sendnullto clear it.retrievalContextTransformerIdstring | nullThe id of a transformer that extracts the retrieved context. Send this or
retrievalContextKeyPath, never both. Sendnullto clear it.toolsCalledTransformerIdstring | nullThe id of a transformer that extracts the tools called. Send this or
toolsCalledKeyPath, never both. Sendnullto clear it.stateTransformerIdstring | nullThe id of a transformer that extracts the conversation state. Send this or
stateKeyPath, never both. Sendnullto clear it.inputTokenCountTransformerIdstring | nullThe id of a transformer that extracts the prompt token count. Send this or
inputTokenCountKeyPath, never both. Sendnullto clear it.outputTokenCountTransformerIdstring | nullThe id of a transformer that extracts the completion token count. Send this or
outputTokenCountKeyPath, never both. Sendnullto clear it.tokenCostTransformerIdstring | nullThe id of a transformer that extracts the cost of the call. Send this or
tokenCostKeyPath, never both. Sendnullto clear it.promptsobject | nullThe prompts to substitute into the request body, keyed by the placeholder they fill in
payload. The map replaces the connection's current prompts rather than merging into them.
Response
Create AI Connection succeeded.
successbooleanIndicates if the request was successful.
dataobjectA reference to an AI connection by its id.
Show 1 propertyHide 1 property
idstringThe id of the AI connection, generated by Confident AI.
linkstringThis is the URL of the resource on the Confident AI platform.
deprecatedbooleanIndicates if this endpoint is deprecated.