Skip to main content

NextToken SDK - Simple client for the NextToken APIs and Gateway

Project description

NextToken Python SDK

Simple Python client for the NextToken Gateway - an OpenAI-compatible LLM proxy.

Installation

pip install nexttoken

Quick Start

from nexttoken import NextToken

# Initialize with your API key
client = NextToken(api_key="your-api-key")

# Use like the OpenAI SDK
response = client.chat.completions.create(
    model="gpt-4o",  # or "claude-3-5-sonnet", "gemini-2.5-flash"
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

Available Models

  • OpenAI models
  • Anthropic models
  • Gemini models
  • Openrouter models

Embeddings

from nexttoken import NextToken

client = NextToken(api_key="your-api-key")

response = client.embeddings.create(
    model="text-embedding-3-small",
    input="Your text to embed"
)

print(response.data[0].embedding)

Integrations

Connect and use third-party services (Gmail, Slack, etc.) through your NextToken account.

from nexttoken import NextToken

client = NextToken(api_key="your-api-key")

# List connected integrations
integrations = client.integrations.list()
print(integrations)

# List available actions for an app
actions = client.integrations.list_actions("gmail")
print(actions)

# Invoke a function
result = client.integrations.invoke(
    app="gmail",
    function_key="gmail-send-email",
    args={
        "to": "user@example.com",
        "subject": "Hello",
        "body": "Hello from NextToken!"
    }
)
print(result)

Web Search

Search the web programmatically using NextToken's search API.

from nexttoken import NextToken

client = NextToken(api_key="your-api-key")

# Basic search
results = client.search.query("latest AI developments")
for r in results:
    print(r["title"], r["url"])

# With domain filtering
results = client.search.query(
    "machine learning papers",
    num_results=10,
    include_domains=["arxiv.org", "nature.com"]
)

Get Your API Key

Sign up at nexttoken.co and get your API key from Settings.

License

MIT

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

nexttoken-0.3.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

nexttoken-0.3.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file nexttoken-0.3.0.tar.gz.

File metadata

  • Download URL: nexttoken-0.3.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for nexttoken-0.3.0.tar.gz
Algorithm Hash digest
SHA256 76fb8b34987e9025c816350067610f400f1a5ef56f09da76de5c8ef2910329e7
MD5 7c122209c87298d646ae42c72d3958d7
BLAKE2b-256 870ae9579fda1e761c830d879ad6bab761d94076f64c1ebda2e3e82b43ed7321

See more details on using hashes here.

File details

Details for the file nexttoken-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nexttoken-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for nexttoken-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2881b36a790c8629eb0ac101b482f26cb478e7241cda890b3d7f745066773ffa
MD5 436f8df8ea049554e0e708a6272842d9
BLAKE2b-256 732c972d1bbb8aef58804ed17c4170694d0559d0eb824da54d2bcacab800391f

See more details on using hashes here.

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