Skip to content

xAI

Setup

Get your API key from the xAI Console, and export it as an environment variable:

export GROK_API_KEY=<GROK_API_KEY>

Examples

from toolfront import Database

db = Database("postgresql://user:pass@host/db")

# Latest Grok version
result = db.ask(..., model="grok:grok-2-1212")

xAI Model Names

Always specify an xAI model with the grok: prefix.