Amazon SageMaker provider

Related Documentation
Minimum Version
AI Gateway - 2.0
Incompatible with
on-prem
Tags
#ai

You can proxy requests to Amazon SageMaker AI models through AI Gateway by creating AI Model Provider and AI Model entities. This reference documents all supported AI capabilities, configuration requirements, and provider-specific details needed for proper integration.

Upstream paths

AI Gateway automatically routes requests to the appropriate Amazon SageMaker API endpoints. The following table shows the upstream paths used for each capability.

Capability

Path template

Description

Upstream path or API

Generate /chat/completions Text generation for chat completions and responses /endpoints/{endpoint_name}/invocations (or /endpoints/{endpoint_name}/invocations-response-stream for streaming)

Supported capabilities

The following tables show the AI capabilities supported by the Amazon SageMaker provider when configuring AI Models.

By default, AI Gateway uses the path templates shown in the tables below (e.g., /chat/completions, /embeddings, etc.). To customize these paths, configure the config.paths field in your AI Model entity. Custom paths take the form {configured_path}/{template_path} — for example, if you set a custom path of /v2, requests to /embeddings would be routed to /v2/embeddings.

Text generation

Support for Amazon SageMaker text generation capabilities:

Capability

Streaming

Model example

Path template

Min version

generate Supported User-defined (the name of your SageMaker endpoint) /chat/completions 2.0

Amazon SageMaker base URL

The base URL is https://runtime.sagemaker.{region}.amazonaws.com.

AI Gateway uses this URL automatically. You only need to configure a URL if you’re using a self-hosted or Amazon SageMaker-compatible endpoint, in which case set the upstream_url option in your AI Model configuration.

Configure Amazon SageMaker

To use Amazon SageMaker with AI Gateway, configure a new AI Model Provider. You can then access supported AI Models from Amazon SageMaker.

Here’s a minimal configuration for chat completions:

Authentication with AWS

For Amazon SageMaker, set auth to sagemaker and provide static IAM user credentials under aws, or omit them to fall back to the default AWS credentials provider chain (EC2 instance profiles, environment variables, and so on):

  • access_key_id (optional): AWS access key ID for static IAM user credentials. Overrides the AWS_ACCESS_KEY_ID environment variable.
  • secret_access_key (optional): AWS secret access key paired with access_key_id. Overrides the AWS_SECRET_ACCESS_KEY environment variable.
  • session_token (optional): AWS session token for temporary credentials. Overrides the AWS_SESSION_TOKEN environment variable.

Amazon SageMaker can also use basic auth instead. See Outbound authentication on the AI Model Provider entity page for the full list of auth types.

Configure a model target for Amazon SageMaker

Only the generate capability is supported for Amazon SageMaker targets.

A target is an entry in the targets array on the AI Model entity, not the AI Model Provider. The target name is the name of your SageMaker endpoint. Beyond the common target options (name, provider, weight), a target routing to Amazon SageMaker supports these config fields, grouped under aws and target:

Field

Description

aws.region The AWS region hosting the SageMaker endpoint. Overrides the AWS_REGION environment variable.
aws.assume_role_arn IAM role ARN to assume for temporary credentials. Requires aws.role_session_name.
aws.role_session_name Session name for the assumed role. Required if aws.assume_role_arn is set.
aws.sts_endpoint_url Custom STS endpoint used when assuming a role.
target.model The model artifact to invoke on a multi-model endpoint. Sets the X-Amzn-SageMaker-Target-Model header.
target.variant The production variant to invoke on a multi-variant endpoint. Sets the X-Amzn-SageMaker-Target-Variant header.
target.container_hostname The container hostname to invoke on a multi-container endpoint. Sets the X-Amzn-SageMaker-Target-Container-Hostname header.

The following target routes to a SageMaker endpoint in us-east-1 and selects a specific model, variant, and container on a multi-model endpoint:

targets:
  - name: my-sagemaker-endpoint
    provider: my-sagemaker-account
    config:
      type: sagemaker
      aws:
        region: us-east-1
      target:
        model: my-model.tar.gz
        variant: production-variant-1
        container_hostname: container-1

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!