Poe API
Grok 4 is xAI's latest and most intelligent language model. It features state-of-the-art capabilities in coding, reasoning, and answering questions. It excels at handling complex and multi-step tasks. Reasoning traces are not available via the xAI API.
Powered by a server managed by @xAI. Learn more
- OFFICIAL
Build with Grok-4 using the Poe API
Start by creating an API key, for use with any bot on Poe:
Code samples
python
import openai
client = openai.OpenAI(
api_key = "YOUR_POE_API_KEY", # or os.getenv("POE_API_KEY")
base_url = "https://api.poe.com/v1",
)
chat = client.chat.completions.create(
model = "grok-4",
messages = [{
"role": "user",
"content": "Write a simple function that generates the nth element of the Fibonacci sequence for an input n and then optimize its implementation."
}]
)
print(chat.choices[0].message.content)See the full documentation for comprehensive guidance on getting started.