A Python client for interacting with the Nebula API, providing a seamless interface for chat-based interactions with thirdweb's Nebula service.
pip install thirdweb-nebula
from nebula import Nebula
# Initialize the client
client = Nebula(
base_url="https://nebula-api.thirdweb.com",
secret_key="your-secret-key"
)
# Basic chat request
response = client.chat("Hello, Nebula!")
print(response.message)
# Streaming chat request
for chunk in client.chat("Hello, Nebula!", stream=True):
print(chunk, end="")
- Synchronous and streaming chat responses
- Session management
- Configurable execution environments
- Context filtering capabilities
- Custom model selection
- Type-safe request/response handling with Pydantic
Filter the context of your chat based on specific blockchain parameters:
from nebula import ContextFilter
context = ContextFilter(
chain_ids=["1", "137"],
contract_addresses=["0x..."],
wallet_addresses=["0x..."]
)
response = client.chat(
"Tell me about my contracts",
context_filter=context
)
Configure how your requests are executed:
from nebula import ExecuteConfig
config = ExecuteConfig(
mode="client",
signer_wallet_address="0x...",
engine_url="https://your-engine.com"
)
response = client.chat(
"Execute this transaction",
execute_config=config
)
Maintain conversation context across multiple messages:
response = client.chat(
"Remember this conversation",
session_id="unique-session-id"
)
The SDK provides custom exceptions for proper error handling:
from nebula import NebulaAPIError
try:
response = client.chat("Hello")
except NebulaAPIError as e:
print(f"API Error: {e}")
The client can be configured with:
base_url
: The base URL for the Nebula API (defaults to "https://nebula-api.thirdweb.com")secret_key
: Your thirdweb API secret key for authentication
- Python 3.12+
requests
pydantic
pytest tests/
[License Type] - See LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.