mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
feat: support custom bedrock base url (#21582)
Closes https://github.com/coder/aibridge/issues/126 Depends on https://github.com/coder/aibridge/pull/131 --------- Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
+8
-1
@@ -109,11 +109,18 @@ AI BRIDGE OPTIONS:
|
||||
The access key secret to use with the access key to authenticate
|
||||
against the AWS Bedrock API.
|
||||
|
||||
--aibridge-bedrock-base-url string, $CODER_AIBRIDGE_BEDROCK_BASE_URL
|
||||
The base URL to use for the AWS Bedrock API. Use this setting to
|
||||
specify an exact URL to use. Takes precedence over
|
||||
CODER_AIBRIDGE_BEDROCK_REGION.
|
||||
|
||||
--aibridge-bedrock-model string, $CODER_AIBRIDGE_BEDROCK_MODEL (default: global.anthropic.claude-sonnet-4-5-20250929-v1:0)
|
||||
The model to use when making requests to the AWS Bedrock API.
|
||||
|
||||
--aibridge-bedrock-region string, $CODER_AIBRIDGE_BEDROCK_REGION
|
||||
The AWS Bedrock API region.
|
||||
The AWS Bedrock API region to use. Constructs a base URL to use for
|
||||
the AWS Bedrock API in the form of
|
||||
'https://bedrock-runtime.<region>.amazonaws.com'.
|
||||
|
||||
--aibridge-bedrock-small-fastmodel string, $CODER_AIBRIDGE_BEDROCK_SMALL_FAST_MODEL (default: global.anthropic.claude-haiku-4-5-20251001-v1:0)
|
||||
The small fast model to use when making requests to the AWS Bedrock
|
||||
|
||||
+6
-1
@@ -746,7 +746,12 @@ aibridge:
|
||||
# The base URL of the Anthropic API.
|
||||
# (default: https://api.anthropic.com/, type: string)
|
||||
anthropic_base_url: https://api.anthropic.com/
|
||||
# The AWS Bedrock API region.
|
||||
# The base URL to use for the AWS Bedrock API. Use this setting to specify an
|
||||
# exact URL to use. Takes precedence over CODER_AIBRIDGE_BEDROCK_REGION.
|
||||
# (default: <unset>, type: string)
|
||||
bedrock_base_url: ""
|
||||
# The AWS Bedrock API region to use. Constructs a base URL to use for the AWS
|
||||
# Bedrock API in the form of 'https://bedrock-runtime.<region>.amazonaws.com'.
|
||||
# (default: <unset>, type: string)
|
||||
bedrock_region: ""
|
||||
# The model to use when making requests to the AWS Bedrock API.
|
||||
|
||||
Generated
+3
@@ -12018,6 +12018,9 @@ const docTemplate = `{
|
||||
"access_key_secret": {
|
||||
"type": "string"
|
||||
},
|
||||
"base_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
Generated
+3
@@ -10670,6 +10670,9 @@
|
||||
"access_key_secret": {
|
||||
"type": "string"
|
||||
},
|
||||
"base_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
+21
-8
@@ -3394,14 +3394,26 @@ Write out the current server config as YAML to stdout.`,
|
||||
Annotations: serpent.Annotations{}.Mark(annotationSecretKey, "true"),
|
||||
},
|
||||
{
|
||||
Name: "AI Bridge Bedrock Region",
|
||||
Description: "The AWS Bedrock API region.",
|
||||
Flag: "aibridge-bedrock-region",
|
||||
Env: "CODER_AIBRIDGE_BEDROCK_REGION",
|
||||
Value: &c.AI.BridgeConfig.Bedrock.Region,
|
||||
Default: "",
|
||||
Group: &deploymentGroupAIBridge,
|
||||
YAML: "bedrock_region",
|
||||
Name: "AI Bridge Bedrock Base URL",
|
||||
Description: "The base URL to use for the AWS Bedrock API. Use this setting to specify an exact URL to use. Takes precedence " +
|
||||
"over CODER_AIBRIDGE_BEDROCK_REGION.",
|
||||
Flag: "aibridge-bedrock-base-url",
|
||||
Env: "CODER_AIBRIDGE_BEDROCK_BASE_URL",
|
||||
Value: &c.AI.BridgeConfig.Bedrock.BaseURL,
|
||||
Default: "",
|
||||
Group: &deploymentGroupAIBridge,
|
||||
YAML: "bedrock_base_url",
|
||||
},
|
||||
{
|
||||
Name: "AI Bridge Bedrock Region",
|
||||
Description: "The AWS Bedrock API region to use. Constructs a base URL to use for the AWS Bedrock API in the form of " +
|
||||
"'https://bedrock-runtime.<region>.amazonaws.com'.",
|
||||
Flag: "aibridge-bedrock-region",
|
||||
Env: "CODER_AIBRIDGE_BEDROCK_REGION",
|
||||
Value: &c.AI.BridgeConfig.Bedrock.Region,
|
||||
Default: "",
|
||||
Group: &deploymentGroupAIBridge,
|
||||
YAML: "bedrock_region",
|
||||
},
|
||||
{
|
||||
Name: "AI Bridge Bedrock Access Key",
|
||||
@@ -3727,6 +3739,7 @@ type AIBridgeAnthropicConfig struct {
|
||||
}
|
||||
|
||||
type AIBridgeBedrockConfig struct {
|
||||
BaseURL serpent.String `json:"base_url" typescript:",notnull"`
|
||||
Region serpent.String `json:"region" typescript:",notnull"`
|
||||
AccessKey serpent.String `json:"access_key" typescript:",notnull"`
|
||||
AccessKeySecret serpent.String `json:"access_key_secret" typescript:",notnull"`
|
||||
|
||||
@@ -58,6 +58,11 @@ Set the following when routing [Amazon Bedrock](https://coder.com/docs/reference
|
||||
- `CODER_AIBRIDGE_BEDROCK_MODEL` or `--aibridge-bedrock-model`
|
||||
- `CODER_AIBRIDGE_BEDROCK_SMALL_FAST_MODEL` or `--aibridge-bedrock-small-fast-model`
|
||||
|
||||
> [!NOTE]
|
||||
> `CODER_AIBRIDGE_BEDROCK_BASE_URL` or `--aibridge-bedrock-base-url` may be used instead of `CODER_AIBRIDGE_BEDROCK_REGION`/`--aibridge-bedrock-region`
|
||||
if you would like to specify a URL which does not follow the form of `https://bedrock-runtime.<region>.amazonaws.com` - for example if using a
|
||||
proxy between AI Bridge and AWS Bedrock.
|
||||
|
||||
#### Obtaining Bedrock credentials
|
||||
|
||||
1. **Choose a region** where you want to use Bedrock.
|
||||
|
||||
Generated
+1
@@ -181,6 +181,7 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \
|
||||
"bedrock": {
|
||||
"access_key": "string",
|
||||
"access_key_secret": "string",
|
||||
"base_url": "string",
|
||||
"model": "string",
|
||||
"region": "string",
|
||||
"small_fast_model": "string"
|
||||
|
||||
Generated
+6
@@ -357,6 +357,7 @@
|
||||
{
|
||||
"access_key": "string",
|
||||
"access_key_secret": "string",
|
||||
"base_url": "string",
|
||||
"model": "string",
|
||||
"region": "string",
|
||||
"small_fast_model": "string"
|
||||
@@ -369,6 +370,7 @@
|
||||
|---------------------|--------|----------|--------------|-------------|
|
||||
| `access_key` | string | false | | |
|
||||
| `access_key_secret` | string | false | | |
|
||||
| `base_url` | string | false | | |
|
||||
| `model` | string | false | | |
|
||||
| `region` | string | false | | |
|
||||
| `small_fast_model` | string | false | | |
|
||||
@@ -384,6 +386,7 @@
|
||||
"bedrock": {
|
||||
"access_key": "string",
|
||||
"access_key_secret": "string",
|
||||
"base_url": "string",
|
||||
"model": "string",
|
||||
"region": "string",
|
||||
"small_fast_model": "string"
|
||||
@@ -749,6 +752,7 @@
|
||||
"bedrock": {
|
||||
"access_key": "string",
|
||||
"access_key_secret": "string",
|
||||
"base_url": "string",
|
||||
"model": "string",
|
||||
"region": "string",
|
||||
"small_fast_model": "string"
|
||||
@@ -2672,6 +2676,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
"bedrock": {
|
||||
"access_key": "string",
|
||||
"access_key_secret": "string",
|
||||
"base_url": "string",
|
||||
"model": "string",
|
||||
"region": "string",
|
||||
"small_fast_model": "string"
|
||||
@@ -3224,6 +3229,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
"bedrock": {
|
||||
"access_key": "string",
|
||||
"access_key_secret": "string",
|
||||
"base_url": "string",
|
||||
"model": "string",
|
||||
"region": "string",
|
||||
"small_fast_model": "string"
|
||||
|
||||
Generated
+11
-1
@@ -1742,6 +1742,16 @@ The base URL of the Anthropic API.
|
||||
|
||||
The key to authenticate against the Anthropic API.
|
||||
|
||||
### --aibridge-bedrock-base-url
|
||||
|
||||
| | |
|
||||
|-------------|-----------------------------------------------|
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_AIBRIDGE_BEDROCK_BASE_URL</code> |
|
||||
| YAML | <code>aibridge.bedrock_base_url</code> |
|
||||
|
||||
The base URL to use for the AWS Bedrock API. Use this setting to specify an exact URL to use. Takes precedence over CODER_AIBRIDGE_BEDROCK_REGION.
|
||||
|
||||
### --aibridge-bedrock-region
|
||||
|
||||
| | |
|
||||
@@ -1750,7 +1760,7 @@ The key to authenticate against the Anthropic API.
|
||||
| Environment | <code>$CODER_AIBRIDGE_BEDROCK_REGION</code> |
|
||||
| YAML | <code>aibridge.bedrock_region</code> |
|
||||
|
||||
The AWS Bedrock API region.
|
||||
The AWS Bedrock API region to use. Constructs a base URL to use for the AWS Bedrock API in the form of 'https://bedrock-runtime.<region>.amazonaws.com'.
|
||||
|
||||
### --aibridge-bedrock-access-key
|
||||
|
||||
|
||||
@@ -68,11 +68,12 @@ func newAIBridgeDaemon(coderAPI *coderd.API) (*aibridged.Server, error) {
|
||||
}
|
||||
|
||||
func getBedrockConfig(cfg codersdk.AIBridgeBedrockConfig) *aibridge.AWSBedrockConfig {
|
||||
if cfg.Region.String() == "" && cfg.AccessKey.String() == "" && cfg.AccessKeySecret.String() == "" {
|
||||
if cfg.Region.String() == "" && cfg.BaseURL.String() == "" && cfg.AccessKey.String() == "" && cfg.AccessKeySecret.String() == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &aibridge.AWSBedrockConfig{
|
||||
BaseURL: cfg.BaseURL.String(),
|
||||
Region: cfg.Region.String(),
|
||||
AccessKey: cfg.AccessKey.String(),
|
||||
AccessKeySecret: cfg.AccessKeySecret.String(),
|
||||
|
||||
+8
-1
@@ -110,11 +110,18 @@ AI BRIDGE OPTIONS:
|
||||
The access key secret to use with the access key to authenticate
|
||||
against the AWS Bedrock API.
|
||||
|
||||
--aibridge-bedrock-base-url string, $CODER_AIBRIDGE_BEDROCK_BASE_URL
|
||||
The base URL to use for the AWS Bedrock API. Use this setting to
|
||||
specify an exact URL to use. Takes precedence over
|
||||
CODER_AIBRIDGE_BEDROCK_REGION.
|
||||
|
||||
--aibridge-bedrock-model string, $CODER_AIBRIDGE_BEDROCK_MODEL (default: global.anthropic.claude-sonnet-4-5-20250929-v1:0)
|
||||
The model to use when making requests to the AWS Bedrock API.
|
||||
|
||||
--aibridge-bedrock-region string, $CODER_AIBRIDGE_BEDROCK_REGION
|
||||
The AWS Bedrock API region.
|
||||
The AWS Bedrock API region to use. Constructs a base URL to use for
|
||||
the AWS Bedrock API in the form of
|
||||
'https://bedrock-runtime.<region>.amazonaws.com'.
|
||||
|
||||
--aibridge-bedrock-small-fastmodel string, $CODER_AIBRIDGE_BEDROCK_SMALL_FAST_MODEL (default: global.anthropic.claude-haiku-4-5-20251001-v1:0)
|
||||
The small fast model to use when making requests to the AWS Bedrock
|
||||
|
||||
@@ -473,7 +473,7 @@ require (
|
||||
github.com/anthropics/anthropic-sdk-go v1.19.0
|
||||
github.com/brianvoe/gofakeit/v7 v7.14.0
|
||||
github.com/coder/agentapi-sdk-go v0.0.0-20250505131810-560d1d88d225
|
||||
github.com/coder/aibridge v0.3.1-0.20260120123323-c997d7bed20e
|
||||
github.com/coder/aibridge v0.3.1-0.20260121122740-e164b504fc52
|
||||
github.com/coder/aisdk-go v0.0.9
|
||||
github.com/coder/boundary v0.0.1-alpha
|
||||
github.com/coder/preview v1.0.4
|
||||
|
||||
@@ -927,8 +927,8 @@ github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y
|
||||
github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f/go.mod h1:HlzOvOjVBOfTGSRXRyY0OiCS/3J1akRGQQpRO/7zyF4=
|
||||
github.com/coder/agentapi-sdk-go v0.0.0-20250505131810-560d1d88d225 h1:tRIViZ5JRmzdOEo5wUWngaGEFBG8OaE1o2GIHN5ujJ8=
|
||||
github.com/coder/agentapi-sdk-go v0.0.0-20250505131810-560d1d88d225/go.mod h1:rNLVpYgEVeu1Zk29K64z6Od8RBP9DwqCu9OfCzh8MR4=
|
||||
github.com/coder/aibridge v0.3.1-0.20260120123323-c997d7bed20e h1:FcXw+6MXWFTrRYKaYuao6IRLdt/aqfonFfSDh0wFTa8=
|
||||
github.com/coder/aibridge v0.3.1-0.20260120123323-c997d7bed20e/go.mod h1:x45BE/NNDesDN1eWy4bsg81QsL6ou7xXPIeQr0ePETQ=
|
||||
github.com/coder/aibridge v0.3.1-0.20260121122740-e164b504fc52 h1:UcsOXQH881tXPpU75Cz4GpTmV7JTZ7GS8AdA0QdAAC4=
|
||||
github.com/coder/aibridge v0.3.1-0.20260121122740-e164b504fc52/go.mod h1:x45BE/NNDesDN1eWy4bsg81QsL6ou7xXPIeQr0ePETQ=
|
||||
github.com/coder/aisdk-go v0.0.9 h1:Vzo/k2qwVGLTR10ESDeP2Ecek1SdPfZlEjtTfMveiVo=
|
||||
github.com/coder/aisdk-go v0.0.9/go.mod h1:KF6/Vkono0FJJOtWtveh5j7yfNrSctVTpwgweYWSp5M=
|
||||
github.com/coder/boundary v0.0.1-alpha h1:6shUQ2zkrWrfbgVcqWvpV2ibljOQvPvYqTctWBkKoUA=
|
||||
|
||||
Generated
+1
@@ -18,6 +18,7 @@ export interface AIBridgeAnthropicConfig {
|
||||
|
||||
// From codersdk/deployment.go
|
||||
export interface AIBridgeBedrockConfig {
|
||||
readonly base_url: string;
|
||||
readonly region: string;
|
||||
readonly access_key: string;
|
||||
readonly access_key_secret: string;
|
||||
|
||||
Reference in New Issue
Block a user