mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
8369fa88fd
Two new columns added to aibridge_token_usages: - cache_read_input_tokens (BIGINT, default 0) - cache_write_input_tokens (BIGINT, default 0) Migration backfills existing rows by extracting values from the metadata JSONB column (cache_read_input, input_cached, prompt_cached for reads (max value selected since only 1 should be set), cache_creation_input for writes). All references to data from metadata were updated to reference new columns. No other changes then changing where data is extracted from. Requires aibridge library version bump to include: https://github.com/coder/aibridge/pull/229 Fixes: https://github.com/coder/aibridge/issues/150
12 KiB
Generated
12 KiB
Generated
AI Bridge
List AI Bridge clients
Code samples
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/aibridge/clients \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
GET /aibridge/clients
Example responses
200 Response
[
"string"
]
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | array of string |
Response Schema
To perform this operation, you must be authenticated. Learn more.
List AI Bridge interceptions
Code samples
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/aibridge/interceptions \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
GET /aibridge/interceptions
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
q |
query | string | false | Search query in the format key:value. Available keys are: initiator, provider, model, started_after, started_before. |
limit |
query | integer | false | Page limit |
after_id |
query | string | false | Cursor pagination after ID (cannot be used with offset) |
offset |
query | integer | false | Offset pagination (cannot be used with after_id) |
Example responses
200 Response
{
"count": 0,
"results": [
{
"api_key_id": "string",
"client": "string",
"ended_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"initiator": {
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"username": "string"
},
"metadata": {
"property1": null,
"property2": null
},
"model": "string",
"provider": "string",
"provider_name": "string",
"started_at": "2019-08-24T14:15:22Z",
"token_usages": [
{
"cache_read_input_tokens": 0,
"cache_write_input_tokens": 0,
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"input_tokens": 0,
"interception_id": "34d9b688-63ad-46f4-88b5-665c1e7f7824",
"metadata": {
"property1": null,
"property2": null
},
"output_tokens": 0,
"provider_response_id": "string"
}
],
"tool_usages": [
{
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"injected": true,
"input": "string",
"interception_id": "34d9b688-63ad-46f4-88b5-665c1e7f7824",
"invocation_error": "string",
"metadata": {
"property1": null,
"property2": null
},
"provider_response_id": "string",
"server_url": "string",
"tool": "string"
}
],
"user_prompts": [
{
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"interception_id": "34d9b688-63ad-46f4-88b5-665c1e7f7824",
"metadata": {
"property1": null,
"property2": null
},
"prompt": "string",
"provider_response_id": "string"
}
]
}
]
}
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | codersdk.AIBridgeListInterceptionsResponse |
To perform this operation, you must be authenticated. Learn more.
List AI Bridge models
Code samples
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/aibridge/models \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
GET /aibridge/models
Example responses
200 Response
[
"string"
]
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | array of string |
Response Schema
To perform this operation, you must be authenticated. Learn more.
List AI Bridge sessions
Code samples
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/aibridge/sessions \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
GET /aibridge/sessions
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
q |
query | string | false | Search query in the format key:value. Available keys are: initiator, provider, model, client, session_id, started_after, started_before. |
limit |
query | integer | false | Page limit |
after_session_id |
query | string | false | Cursor pagination after session ID (cannot be used with offset) |
offset |
query | integer | false | Offset pagination (cannot be used with after_session_id) |
Example responses
200 Response
{
"count": 0,
"sessions": [
{
"client": "string",
"ended_at": "2019-08-24T14:15:22Z",
"id": "string",
"initiator": {
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"username": "string"
},
"last_prompt": "string",
"metadata": {
"property1": null,
"property2": null
},
"models": [
"string"
],
"providers": [
"string"
],
"started_at": "2019-08-24T14:15:22Z",
"threads": 0,
"token_usage_summary": {
"cache_read_input_tokens": 0,
"cache_write_input_tokens": 0,
"input_tokens": 0,
"output_tokens": 0
}
}
]
}
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | codersdk.AIBridgeListSessionsResponse |
To perform this operation, you must be authenticated. Learn more.
Get AI Bridge session threads
Code samples
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/aibridge/sessions/{session_id} \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
GET /aibridge/sessions/{session_id}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
session_id |
path | string | true | Session ID (client_session_id or interception UUID) |
after_id |
query | string | false | Thread pagination cursor (forward/older) |
before_id |
query | string | false | Thread pagination cursor (backward/newer) |
limit |
query | integer | false | Number of threads per page (default 50) |
Example responses
200 Response
{
"client": "string",
"ended_at": "2019-08-24T14:15:22Z",
"id": "string",
"initiator": {
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"username": "string"
},
"metadata": {
"property1": null,
"property2": null
},
"models": [
"string"
],
"page_ended_at": "2019-08-24T14:15:22Z",
"page_started_at": "2019-08-24T14:15:22Z",
"providers": [
"string"
],
"started_at": "2019-08-24T14:15:22Z",
"threads": [
{
"agentic_actions": [
{
"model": "string",
"thinking": [
{
"text": "string"
}
],
"token_usage": {
"cache_read_input_tokens": 0,
"cache_write_input_tokens": 0,
"input_tokens": 0,
"metadata": {
"property1": null,
"property2": null
},
"output_tokens": 0
},
"tool_calls": [
{
"created_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"injected": true,
"input": "string",
"interception_id": "34d9b688-63ad-46f4-88b5-665c1e7f7824",
"metadata": {
"property1": null,
"property2": null
},
"provider_response_id": "string",
"server_url": "string",
"tool": "string"
}
]
}
],
"ended_at": "2019-08-24T14:15:22Z",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"model": "string",
"prompt": "string",
"provider": "string",
"started_at": "2019-08-24T14:15:22Z",
"token_usage": {
"cache_read_input_tokens": 0,
"cache_write_input_tokens": 0,
"input_tokens": 0,
"metadata": {
"property1": null,
"property2": null
},
"output_tokens": 0
}
}
],
"token_usage_summary": {
"cache_read_input_tokens": 0,
"cache_write_input_tokens": 0,
"input_tokens": 0,
"metadata": {
"property1": null,
"property2": null
},
"output_tokens": 0
}
}
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | OK | codersdk.AIBridgeSessionThreadsResponse |
To perform this operation, you must be authenticated. Learn more.