Skip to content

Add host parameter to API client#45

Merged
nicoche merged 1 commit into
mainfrom
vibe/add-host-parameter-9ec299
Jun 9, 2026
Merged

Add host parameter to API client#45
nicoche merged 1 commit into
mainfrom
vibe/add-host-parameter-9ec299

Conversation

@nicoche

@nicoche nicoche commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Priority:

Summary

  • Add host parameter to Sandbox.create() and AsyncSandbox.create() methods
  • Add host parameter to Sandbox.get_from_id() and AsyncSandbox.get_from_id() methods
  • The host parameter allows users to directly specify the Koyeb API host URL instead of relying solely on the KOYEB_API_HOST environment variable

Changes

  • Modified Sandbox.__init__() to accept and store the host parameter
  • Updated Sandbox.create() to accept host parameter and pass it through to _create_sync()
  • Updated Sandbox._create_sync() to accept host parameter and pass it to get_api_clients()
  • Updated Sandbox.get_from_id() to accept host parameter and pass it to get_api_clients()
  • Updated all internal get_api_clients() calls in Sandbox methods to use self.host
  • Updated AsyncSandbox.create() to accept host parameter and pass it through
  • Updated AsyncSandbox.get_from_id() to accept host parameter and pass it through

Usage Example

from koyeb.sandbox import AsyncSandbox

# Now you can specify the host directly
sandbox = await AsyncSandbox.create(
    region="na",
    host="https://custom.koyeb.com"
)

# Or use environment variable (existing behavior)
# KOYEB_API_HOST=https://custom.koyeb.com
sandbox = await AsyncSandbox.create(region="na")

Verification

  • All existing tests pass
  • The host parameter is properly stored in the Sandbox instance
  • The host parameter is correctly passed to get_api_clients() which already supported it

Priority:
- Env variable KOYEB_API_HOST
- Parameter host
- "https://app.koyeb.com" (default)

This change allows users to directly specify the Koyeb API host URL when
creating sandboxes, instead of relying solely on the KOYEB_API_HOST environment
variable. The host parameter is now available in:

- Sandbox.create(host=...)
- AsyncSandbox.create(host=...)
- Sandbox.get_from_id(host=...)
- AsyncSandbox.get_from_id(host=...)

The host parameter is passed through to get_api_clients() which already
supported it. This makes the SDK more flexible for users who need to
connect to different Koyeb API endpoints.

Co-authored-by: nicoche <nicoche@users.noreply.github.com>
@nicoche nicoche force-pushed the vibe/add-host-parameter-9ec299 branch from 9d97a49 to a25446d Compare June 9, 2026 15:37
@nicoche nicoche changed the title Add host parameter to AsyncSandbox.create and Sandbox.create Add host parameter to API client Jun 9, 2026
@nicoche nicoche marked this pull request as ready for review June 9, 2026 15:38
@nicoche nicoche merged commit 020797f into main Jun 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants