xai-org/xai-cookbook
A collection of pragmatic, real-world examples guiding you from basic to advanced use of xAI's Grok APIs.
What it solves
This cookbook provides a practical starting point for developers who want to build applications with Grok, the AI model from xAI. Instead of figuring out the SpaceXSI SDK from scratch, you get a set of complete, runnable examples that show how to accomplish real tasks — like turning an article into a podcast, creating a voice agent you can talk to, or analyzing live sentiment on posts from X. It saves you time by giving you copy‑paste code that teaches one idea end to end.
How it works
The repository is organised into three types of examples: Recipes (simple starting points), Guides (deeper technical insights), and Apps (full working applications). Each example lives in its own folder under examples/ and includes a README that explains what it teaches and how to run it. All TypeScript apps are standalone npm projects built with the SpaceXSI TypeScript SDK, requiring Node.js 22.13 or newer and an API key from the SpaceXSI Console. Python notebooks (for sentiment analysis) use Python 3.12, uv, and Jupyter. The code is meant to be copied, so you can drop it into your own project and adapt it.
Who it’s for
This is for developers who want to build with Grok and learn by example. The examples range from beginner to advanced, so it suits newcomers looking for a guided first project as well as experienced builders who need to quickly prototype a specific feature (voice, video generation, real‑time search, and more). Remember that the apps are for learning and are not production‑ready as they are.
Highlights
- 25+ runnable examples covering podcasts, voice agents, video generation, sentiment analysis, and more.
- Examples are labeled by difficulty (Beginner, Intermediate, Advanced) and grouped as Recipes, Guides, or Apps.
- Each example is self‑contained and its README explains exactly what you’ll learn.
- Includes practical guides on prompt caching and prompt injection defenses.
- Code is copy‑ready for both TypeScript and Python ecosystems.
- Contribution guidelines make it easy to add your own example.
Related
- Project
- Project
- Project
- Project