> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gloo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Best Practices Overview

> Practical patterns for preparing content, structuring requests, handling failures, and building secure, trustworthy applications on Gloo AI.

These pages cover how to run Gloo AI well in production: keeping your keys and your app safe, choosing models and controlling cost, structuring requests, recovering from failures and testing changes, keeping answers trustworthy, and preparing content. Each one pairs with the API guides and reference pages it builds on. New to building on Gloo? Start with [AI 104: Building with Gloo](https://docs.gloo.com/ai-learning-center/gloo-ai-104/overview.md) in the AI Learning Center.

## Security

> [card] [API Key Security](https://docs.gloo.com/best-practices/api-key-security.md)
>
> Keep keys out of source control and off the browser, use them safely at runtime, and replace a key that may be exposed.

> [card] [Direct Endpoints and Untrusted Content](https://docs.gloo.com/best-practices/untrusted-content.md)
>
> Own safety on direct endpoints, keep outside content as data, check output before acting on it, and give tools the least power they need.

## Models and Cost

> [card] [Choosing, Pinning and Updating Models](https://docs.gloo.com/best-practices/choosing-and-updating-models.md)
>
> Pick a model from the catalog, pin its ID, notice deprecations and redirects early, and move to a new model on your own timeline.

> [card] [Controlling Cost](https://docs.gloo.com/best-practices/cost-control.md)
>
> Match the model to each step, control reasoning and output tokens, get more cache hits, and track spend.

> [card] [Reasoning Models in Production](https://docs.gloo.com/best-practices/reasoning-models.md)
>
> Choose an effort per task, size output limits for thinking and answer, stream long generations, and catch cut-off answers.

## Requests

> [card] [Building with Guarded Endpoints](https://docs.gloo.com/best-practices/guarded-endpoints.md)
>
> Where your task and your user's text go, JSON from a forced tool call, pinning and sizing requests, and handling blocked or moderated replies — on Completions and Responses.

> [card] [Building with System One](https://docs.gloo.com/best-practices/system-one.md)
>
> Write decision questions that get clear answers, act on probabilities rather than the top pick, and handle errors and retries.

> [card] [Images in Conversations](https://docs.gloo.com/best-practices/images-in-conversations.md)
>
> Choose a model that reads images, switch models safely mid-conversation, keep images small, and know what each turn costs.

> [card] [Tools, Structured Output and Agents](https://docs.gloo.com/best-practices/tools-and-structured-output.md)
>
> Write tool definitions, validate arguments, bound tool loops, guard side effects, and get JSON you can rely on.

> [card] [Conversations and Context Windows](https://docs.gloo.com/best-practices/conversations-and-context.md)
>
> Send history, stay inside the context window, trim or summarise, and switch models mid-conversation safely.

## Reliability

> [card] [Error Handling and Retries](https://docs.gloo.com/best-practices/error-handling-and-retries.md)
>
> Which non-streaming errors to retry, backoff with jitter, `Retry-After`, retry budgets, and what to log for support.

> [card] [Handling Streaming Failures](https://docs.gloo.com/best-practices/completions-streaming-failures.md)
>
> How to retry, continue, and surface Completions V2 streaming failures — including retry ceilings, application-level continuation, partial-output UX, and tool-call safety.

> [card] [Testing, Evaluation and Observability](https://docs.gloo.com/best-practices/testing-and-observability.md)
>
> Build a test set, compare models before you switch, and log what each request did for debugging and support.

## Trust

> [card] [Building Trustworthy Grounded Applications](https://docs.gloo.com/best-practices/trustworthy-grounded-applications.md)
>
> The safeguards a RAG application needs on top of grounding: verifying quotations and titles against retrieved sources, prompt contracts, multi-turn self-correction, evaluation, and what to check when grounding looks wrong.

## Content

> [card] [Preparing Content for Ingestion](https://docs.gloo.com/best-practices/ingestion-pattern.md)
>
> A source-agnostic pattern for getting content from any system — CMS, API, database, file library, or feed — into Gloo: adapters, normalization, stable IDs, metadata timing, and when to pre-chunk.

## Next steps

> [card] [Build a Resilient Client](https://docs.gloo.com/tutorials/resilient-client.md)
>
> Put the retry and failover patterns into code, step by step.

> [card] [Errors reference](https://docs.gloo.com/api-reference/general/errors.md)
>
> Every status and error code, and which ones to retry.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.