Connections API
Use Connections APIs to manage your UsageGuard connections programmatically, such as creating a connection, enabling/disabling documents, setting a spending limit, etc.
Connection Model
A connection is at the heart of UsageGuard, it is a way to connect to a different LLM provider and apply a policy to it, all proxied requests are made through a connection.
Property Name | Type | Description | Required | Default |
---|---|---|---|---|
name | string | The name of the connection. | Yes | N/A |
logRequestBody | boolean | Whether to log the request body. | Optional | false |
logResponseBody | boolean | Whether to log the response body. | Optional | false |
disabled | boolean | Whether to disable the connection. Disabled connections will not accept requests. | Optional | false |
DisabledModelIdsList | string[] | A list of model IDs that are disabled for this connection. | Optional | N/A |
enableDocuments | boolean | Whether to enable document processing for this connection. | Optional | false |
forceDocumentsUse | boolean | Whether to force the use of documents for this connection. | Optional | false |
logDocumentsResults | boolean | Whether to log the results of document processing. | Optional | false |
enableSpendingLimit | boolean | Whether to enable the spending limit for this connection. | Optional | false |
spendingPeriod | string | The period for which the spending limit is applied. | Optional | N/A |
spendingLimit | number | The spending limit for the connection. | Optional | N/A |
API Reference
Create Connection
Example shows how to create a connection to an LLM provider (e.g. Open AI, Anthropic, Azure OpenAI, etc.).
Required headers
- Name
Authorization
- Type
- string
- Description
Bearer token for authentication
Required fields
- Name
name
- Type
- string
- Description
The name of the connection.
Optional fields
- Name
spendingLimit
- Type
- number
- Description
The spending limit for the connection.
- Name
logRequestBody
- Type
- boolean
- Description
Whether to log the request body.
- Name
logResponseBody
- Type
- boolean
- Description
Whether to log the response body.
- Name
disabled
- Type
- boolean
- Description
Whether to disable the connection, disabled connections will not accept requests.
Request
curl -X POST https://api.usageguard.com/management/v1/connections \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"baseUrl": "https://api.openai.com",
"providerApiKey": "sk-proj-1234567890",
"logRequestBody": true,
"logResponseBody": false
}'
{
"connectionId": "pb9785sozy"
}
Update Connection
Example shows how to update a connection to an LLM provider, such as updating the base URL or the API key of the LLM provider (Only for Proxy Mode), you can also update different connection options like logRequestBody
, logResponseBody
, disabled
, etc.
Update endpoint supports partial updates, you can omit fields you don't want to update.
Required headers
- Name
Authorization
- Type
- string
- Description
Bearer token for authentication
Required parameters
- Name
connectionId
- Type
- string
- Description
The ID of the connection to update.
Required fields
No required fields
Optional fields
- Name
baseUrl
- Type
- string
- Description
The base URL of the LLM provider.
- Name
ProviderApiKey
- Type
- string
- Description
The API key of the LLM provider (Only for Proxy Mode).
- Name
name
- Type
- string
- Description
The name of the connection.
- Name
logRequestBody
- Type
- boolean
- Description
Whether to log the request body.
- Name
logResponseBody
- Type
- boolean
- Description
Whether to log the response body.
- Name
disabled
- Type
- boolean
- Description
Whether to disable the connection, disabled connections will not accept requests.
Request
curl -X PUT https://api.usageguard.com/management/v1/connections/pb9785sozy \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"name": "Dev Env Anthropic Claude",
"providerApiKey": "anthropic_api_key",
"logRequestBody": true,
"logResponseBody": true
}'
{}
Delete Connection
Example shows how to delete a connection.
Required headers
- Name
Authorization
- Type
- string
- Description
Bearer token for authentication
Required parameters
- Name
connectionId
- Type
- string
- Description
The ID of the connection to delete.
Request
curl -X DELETE https://api.usageguard.com/management/v1/connections/pb9785sozy \
-H "Authorization: Bearer {token}"
{}
Get Connection
Example shows how to get a connection.
Required headers
- Name
Authorization
- Type
- string
- Description
Bearer token for authentication
Required parameters
- Name
connectionId
- Type
- string
- Description
The ID of the connection to get.
Request
curl -X GET https://api.usageguard.com/management/v1/connections/pb9785sozy \
-H "Authorization: Bearer {token}"
{
"connectionId": "pb9785sozy",
"baseUrl": "https://api.usageguard.com",
"providerApiKey": "sk-proj-1234567890",
"logRequestBody": false,
"logResponseBody": false,
"policies": []
}
List Connections
Example shows how to list all connections for your account.
Required headers
- Name
Authorization
- Type
- string
- Description
Bearer token for authentication
Request
curl -X GET https://api.usageguard.com/management/v1/connections \
-H "Authorization: Bearer {token}"
[
{
"connectionId": "a1b2c3d4e5",
"name": "Primary Connection",
"baseUrl": "https://api.usageguard.com",
"logRequestBody": true,
"logResponseBody": true
},
{
"connectionId": "f6g7h8i9j0",
"name": "Backup Connection",
"baseUrl": "https://api.usageguard.com",
"logRequestBody": false,
"logResponseBody": true
},
{
"connectionId": "k1l2m3n4o5",
"name": "Analytics Connection",
"baseUrl": "https://api.usageguard.com",
"logRequestBody": true,
"logResponseBody": false
},
{
"connectionId": "p6q7r8s9t0",
"name": "Development Connection",
"baseUrl": "https://api.usageguard.com",
"logRequestBody": false,
"logResponseBody": false
}
]