SDK Host Configuration
This guide covers how Agenta SDK automatically handles host configuration based on your deployment environment, ensuring proper connectivity for your applications.
Overview
The Agenta SDK automatically handles host configuration based on your deployment environment to ensure proper connectivity.
How it works
The SDK uses the DOCKER_NETWORK_MODE
setting to determine how to handle host URLs:
- Inside Docker containers (network mode: bridge): The SDK automatically converts
localhost
references tohost.docker.internal
to enable communication between containers - Outside Docker (network mode: host/default): The SDK preserves your original host configuration (e.g.,
localhost
remainslocalhost
). Note: "default" meansDOCKER_NETWORK_MODE
is not set when using the SDK outside Docker
Common scenarios
Environment | Network Mode | Host Setting | Result |
---|---|---|---|
AI services running in Docker | bridge | localhost | host.docker.internal |
Local development outside Docker | host/default* | localhost | localhost |
Custom host URL | any | https://my-api.com | https://my-api.com |
*default = DOCKER_NETWORK_MODE
environment variable is not set
Troubleshooting
If you're experiencing connectivity issues, verify that:
- Your host configuration matches your deployment environment
- The
DOCKER_NETWORK_MODE
is correctly set for your environment (bridge for Docker, host/default for outside Docker) - When running outside Docker, use
localhost
or your actual API URL - When running inside Docker, the SDK will handle host resolution automatically