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 NameTypeDescriptionRequiredDefault
namestringThe name of the connection.YesN/A
logRequestBodybooleanWhether to log the request body.Optionalfalse
logResponseBodybooleanWhether to log the response body.Optionalfalse
disabledbooleanWhether to disable the connection. Disabled connections will not accept requests.Optionalfalse
DisabledModelIdsListstring[]A list of model IDs that are disabled for this connection.OptionalN/A
enableDocumentsbooleanWhether to enable document processing for this connection.Optionalfalse
forceDocumentsUsebooleanWhether to force the use of documents for this connection.Optionalfalse
logDocumentsResultsbooleanWhether to log the results of document processing.Optionalfalse
enableSpendingLimitbooleanWhether to enable the spending limit for this connection.Optionalfalse
spendingPeriodstringThe period for which the spending limit is applied.OptionalN/A
spendingLimitnumberThe spending limit for the connection.OptionalN/A

API Reference


POST/management/v1/connections

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

POST
/management/v1/connections
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"
}

PUT/management/v1/connections/:connectionId

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.

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

PUT
/management/v1/connections/:connectionId
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/management/v1/connections/:connectionId

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

DELETE
/management/v1/connections/:connectionId
curl -X DELETE https://api.usageguard.com/management/v1/connections/pb9785sozy \
  -H "Authorization: Bearer {token}"
{}

GET/management/v1/connections/:connectionId

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

GET
/management/v1/connections/:connectionId
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": []
}

GET/management/v1/connections

List Connections

Example shows how to list all connections for your account.

Required headers

  • Name
    Authorization
    Type
    string
    Description

    Bearer token for authentication

Request

GET
/management/v1/connections
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
  }
]

Was this page helpful?