Skip to main content

AgentSIM Python SDK — autonomous OTP relay for AI agents

Project description

agentsim-sdk

Autonomous OTP relay for AI agents. AgentSIM provisions real carrier-routed phone numbers, receives inbound SMS, and delivers parsed OTP codes back to your agent — no human relay needed.

Install

uv add agentsim-sdk

Or with pip:

pip install agentsim-sdk

Quickstart

import agentsim

async with agentsim.provision(agent_id="checkout-bot", country="US") as num:
    await enter_phone_number(num.number)          # "+14155552671"
    otp = await num.wait_for_otp(timeout=60)
    await enter_otp(otp.otp_code)                 # "391847"
# number auto-released

Auth

Set AGENTSIM_API_KEY in your environment, or call agentsim.configure() at startup:

agentsim.configure(api_key="asm_live_xxx")

Get your API key at console.agentsim.dev.

API

agentsim.provision(*, agent_id, country="US", service_url=None, ttl_seconds=3600, webhook_url=None)

Returns an async context manager. Provisions a number on enter, auto-releases on exit (even if the body raises).

async with agentsim.provision(agent_id="stripe-setup", country="US") as num:
    print(num.number)   # E.164 phone number
    print(num.session_id)
    otp = await num.wait_for_otp(timeout=30)
    print(otp.otp_code)

num.wait_for_otp(timeout=60, auto_reroute=False, max_reroutes=2, on_reregistration_needed=None)

Long-polls until an OTP arrives or timeout seconds elapse.

Returns: OtpResult(otp_code, from_number, received_at)

Raises: OtpTimeoutError if no OTP arrives within timeout seconds.

Set auto_reroute=True to automatically provision a replacement number in another country if no OTP arrives. on_reregistration_needed is an async callback (new_number: str, country: str) -> None called when re-registration on the target service is required.

agentsim.provision_sync(...) / num.wait_for_otp_sync(timeout=60)

Synchronous variants for non-async codebases:

with agentsim.provision_sync(agent_id="x") as num:
    otp = num.wait_for_otp_sync(timeout=60)

Error Reference

Exception When
AuthenticationError Missing or invalid API key
PoolExhaustedError No numbers available in requested country
OtpTimeoutError No OTP arrived within timeout seconds
RateLimitError Too many requests — back off and retry
SessionNotFoundError Session expired or already released
CountryNotAllowedError Country not available on current plan

Supported Countries

US

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentsim_sdk-0.16.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentsim_sdk-0.16.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file agentsim_sdk-0.16.0.tar.gz.

File metadata

  • Download URL: agentsim_sdk-0.16.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agentsim_sdk-0.16.0.tar.gz
Algorithm Hash digest
SHA256 0c49beff19535def78c3986db1388839732d01e4be24d8ec14c2be421089d33b
MD5 9ac0d646cc59b23e61057888f1f90038
BLAKE2b-256 0e73f4fdf4a969430687ed654f0c46d8bd02128f33f9cb49e7901f620ed72dec

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentsim_sdk-0.16.0.tar.gz:

Publisher: publish-pypi.yml on agentsimdev/agentsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentsim_sdk-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: agentsim_sdk-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agentsim_sdk-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9707d100e46974a8f29d0fb6ac75142d5e9a20aac13a805cae5860be47bf46e
MD5 044ef2b4a05eb2c89487c5b5d4ef843d
BLAKE2b-256 b333bdd5f1826bd699e05220585829f429bacc7fe65c772104549d0d3183e221

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentsim_sdk-0.16.0-py3-none-any.whl:

Publisher: publish-pypi.yml on agentsimdev/agentsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page