Appearance
Nostr Wallet Connect
WARNING
This feature is experimental and has not been fully rolled out yet. Contact us at info@lightspark.com if you're interested in trying it out.
This example demonstrates how to pay for LLM requests using NWC using an OpenAI-compatible SDK. Note that if it's your first time calling the relay with a specific NWC connection string, then it may assess a 100 satoshi registration fee to prevent abuse.
python
from openai import OpenAI
client = OpenAI(
base_url="https://relay.inferencegrid.ai/",
api_key="nostr+walletconnect://..."
)
client.chat.completions.create(
model="openai/gpt-4o|anthropic/claude-3.7-sonnet",
messages=[
{
"role": "user",
"content": "Tell me a joke!",
},
],
)