Skip to content

Add regional endpoint selection with GatewayArea support#1

Closed
fern-support wants to merge 2 commits into
mainfrom
devin/1765316918-regional-client
Closed

Add regional endpoint selection with GatewayArea support#1
fern-support wants to merge 2 commits into
mainfrom
devin/1765316918-regional-client

Conversation

@fern-support

@fern-support fern-support commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator

Add regional endpoint selection with GatewayArea support

Summary

This PR adds area-based URL selection to the Python SDK, mirroring the functionality added to the Go SDK in this commit.

The implementation creates wrapper clients (RegionalAgora/AsyncRegionalAgora) that extend the base Fern-generated clients, then exports them as Agora/AsyncAgora so users get the enhanced functionality transparently.

New exports:

  • GatewayArea enum: US, EU, APAC, CN
  • RegionalEndpointPool: For advanced users who want to manage the pool lifecycle

Usage:

from agoraio import Agora, GatewayArea

client = Agora(
    gateway_area=GatewayArea.US,
    username="YOUR_USERNAME",
    password="YOUR_PASSWORD",
)

Files added to .fernignore to prevent Fern from overwriting manual changes.

Updates since last revision

  • Fixed regional URL path: Added /api/conversational-ai-agent suffix to regional URLs (e.g., https://api-us-west-1.agora.io/api/conversational-ai-agent) to match the default environment URL structure
  • Verified with test credentials: Successfully connected to regional endpoint and called agents.list() API (returned 0 agents, confirming connectivity works)

Review & Testing Checklist for Human

  • Verify domain configuration matches Go SDK - Check that region prefixes (api-us-west-1, api-cn-east-1, etc.) and domain suffixes (agora.io, sd-rtn.com) match the Go implementation exactly
  • DNS resolution is synchronous - select_best_domain() calls socket.getaddrinfo() during client init. Verify this is acceptable behavior (could block if DNS is slow)
  • Base URL resolved once at construction - The URL is computed once in __init__ and passed to parent. Calling endpoint_pool.next_region() later won't update the client's base URL. Confirm this is the intended behavior.
  • Test the import aliasing - Verify from agoraio import Agora returns RegionalAgora and that existing code without gateway_area still works

Recommended test plan:

  1. Install the SDK locally: pip install -e .
  2. Test basic import: from agoraio import Agora, GatewayArea, RegionalEndpointPool
  3. Create a client with gateway_area=GatewayArea.US and verify the base URL is https://api-us-west-1.agora.io/api/conversational-ai-agent
  4. Create a client without gateway_area and verify it falls back to default environment
  5. Make an API call to verify connectivity

Notes

  • No unit tests included in this PR
  • The TypeScript SDK PR is being created separately
  • CI compile and tests are passing

Link to Devin run: https://app.devin.ai/sessions/3f033f4523f94c2384477ddfc79d00a8
Requested by: blank@buildwithfern.com (@fern-support)

- Add area.py with GatewayArea enum (US, EU, APAC, CN) and RegionalEndpointPool class
- Add regional_client.py with RegionalAgora and AsyncRegionalAgora wrapper clients
- Update __init__.py to export wrapper clients as Agora/AsyncAgora
- Export GatewayArea and RegionalEndpointPool for advanced usage
- Add DNS-based domain selection for optimal connectivity
- Support region cycling for failover scenarios
- Update .fernignore to protect manually added files

Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
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.

1 participant