API fundamentals
Validate one building block at a time and walk away with a starter you can extend. Part of the Cookbook.
- Quickstart: chat completionsPoint the OpenAI SDK at a new base URL and make your first Muse Spark call.
- Streaming responsesStream tokens as they generate and read usage in the final chunk.
- Tool and function callingDetect a tool call, execute it, and feed the result back into the loop.
- Structured outputReturn JSON that matches your schema and parses on the first try.
- Prompt cachingReuse a stable prompt prefix and measure cached tokens.
- Reasoning and thinking tokensSet reasoning effort and replay reasoning across turns.
- Vision inputSend images by URL or base64 and get structured analysis back.
- Long contextPack repo-scale context into a single context window.
- Error handling and retryBack off with jitter and skip retries on client errors.
- Search groundingGround answers in live web search with inline citations.
Mirrored from dev.meta.ai/docs/cookbook/api-fundamentals (synced Oct 30, 2026). Text and examples © Meta. Live demos run on Muse Muse's key.