[Integrations](https://spiral.ai/integrations) › [Codex](https://spiral.ai/integrations/codex) › [USDA food search](https://spiral.ai/integrations/codex/usda-food-search)

# How to Use USDA food search in Codex

Returns matching FoodData Central foods and their record identifiers. Use it to find a food by description or product identifier, then inspect the selected record for its full nutrient details.

|  |  |
| --- | --- |
| Model | USDA food search |
| Available through | Alexandria |
| Category | Maps & Reviews |
| Price | $0.00873 per call. |
| Returns | json |
| Runs | In the background |
| Setup | About 2 minutes, no API key |

## Prompts to try with USDA food search in Codex

- Use USDA food search to find Foundation Foods matching cheddar cheese and populate the project's food picker with the returned descriptions and identifiers.
- Use USDA food search to look this up and give me the result as a table. Save the result in ./assets.
- Pull the latest numbers from USDA food search and tell me what changed since last week.
- Check USDA food search and summarize what you find in three bullet points.
- Pull the newest data from USDA food search and give me the result as a table.

## How to set up USDA food search in Codex

Pick the way that suits you. Each takes about two minutes.

### Use Spiral's MCP server

1. **Add the hosted server**

```bash
codex mcp add spiral --url https://api.spiral.ai/mcp
```

2. **Sign in**: Codex opens the browser: sign in to Spiral and click Authorize. No API key. `codex mcp list` then shows Spiral.

```bash
codex mcp login spiral
```

### Use the Spiral skill

1. **Send Codex this message**: Your agent reads Spiral's skill and sets itself up.

```
set up https://spiral.ai/SKILL.md
```

2. **Sign in or paste a key**: Approve Spiral in the browser, or give the agent a key from the console.

### Use the Spiral CLI

1. **Install and sign in**: Installs the Spiral CLI, signs you in and adds its skill to your coding agents.

```bash
npx -y spiral-cli@latest init
```

### Call the Spiral API

1. **Create an API key**: In the console, under API keys.

2. **Run USDA food search**: One request; the result comes back by polling or a webhook.

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "alexandria",
    "model": "fdc-nal-usda-gov/foods/search_foods",
    "input": {
      "page": 1
    }
  }'
```

Then paste one of the prompts above: Codex finds USDA food search on Spiral, shows the price and runs it.

Setup guide in the docs: https://spiral.ai/docs/quickstarts/codex

## USDA food search tools and prices

- [USDA FoodData Central (fdc.nal.usda.gov) · Search foods](https://spiral.ai/tools/alexandria/fdc-nal-usda-gov/foods/search_foods) (Alexandria): $0.00873 per call.

## Settings you can ask for

| Setting | Allowed values | Default | Description |
| --- | --- | --- | --- |
| page | 1 to 100000 | 1 | 1-based page of 50 results. |
| query |  |  | Search text (food description words, a brand owner, an ingredient or a GTIN/UPC). Empty or omitted lists every food of the selected data types. |
| sort_by | description, publishedDate | description | Sort column: food description (default) or publication date. |
| data_types |  | — | Data types to include, as FoodData Central names them. Default: all five. |
| sort_direction | asc, desc | asc | sort_direction |
| include_nutrients |  | — | Include each result's per-100 g nutrient values (the portal returns them with every result; a Branded page can be large). |

## What can you do with USDA food search in Codex?

Build a food comparison feature with USDA records, nutrient definitions, categories, and nutrient rankings. A coding agent can turn those responses into labeled tables and searchable views in your project.

### Cafeteria ingredient substitution research

Find candidate foods by sodium content, match their descriptions, and inspect complete records. Use nutrient definitions and food categories to organize a comparison of substitutes within the same type of food.

### Plant protein ingredient comparison

Discover foods ranked by reported protein, locate lentil, bean, tofu, and grain records, and compare their nutrient details. Resolve nutrient units and category labels before preparing a purchasing research table.

### Fortified staple food research

Build a reference comparison of enriched and unenriched flour or rice. Resolve the iron definition, discover candidate foods by iron content, verify descriptions, and organize detailed records by USDA category.

### Food comparison teaching tool

Build a classroom explorer with food search, category navigation, nutrient definitions, nutrient rankings, and individual food records. Let students investigate how the chosen food and nutrient change a comparison.

### Recipe ingredient reference sheet

Match oats, milk, nuts, and other recipe ingredients to USDA foods, then collect their nutrient values and available portions in a source-linked reference sheet.

### Packaged product comparison

Find specific packaged foods by name or GTIN and inspect their nutrient and label data. Prepare a comparison for a food buyer using the selected USDA records.

## Overview

- [Alexandria](https://spiral.ai/providers/alexandria)
- [All Codex guides](https://spiral.ai/integrations/codex)

## USDA food search in other agents

- [Amp](https://spiral.ai/integrations/amp/usda-food-search)
- [ChatGPT](https://spiral.ai/integrations/chatgpt/usda-food-search)
- [Claude](https://spiral.ai/integrations/claude-desktop/usda-food-search)
- [Claude Code](https://spiral.ai/integrations/claude-code/usda-food-search)
- [Cline](https://spiral.ai/integrations/cline/usda-food-search)
- [Cursor](https://spiral.ai/integrations/cursor/usda-food-search)
- [Devin](https://spiral.ai/integrations/devin/usda-food-search)
- [dots](https://spiral.ai/integrations/dots/usda-food-search)
- [Factory Droid](https://spiral.ai/integrations/factory-droid/usda-food-search)
- [Gemini](https://spiral.ai/integrations/gemini/usda-food-search)
- [Gemini CLI](https://spiral.ai/integrations/gemini-cli/usda-food-search)
- [Google Antigravity](https://spiral.ai/integrations/antigravity/usda-food-search)
- [goose](https://spiral.ai/integrations/goose/usda-food-search)
- [Grok](https://spiral.ai/integrations/grok/usda-food-search)
- [Grok Build](https://spiral.ai/integrations/grok-build/usda-food-search)
- [Hermes](https://spiral.ai/integrations/hermes/usda-food-search)
- [Instinct](https://spiral.ai/integrations/instinct/usda-food-search)
- [Manus](https://spiral.ai/integrations/manus/usda-food-search)
- [Muse](https://spiral.ai/integrations/muse/usda-food-search)
- [Muse Code](https://spiral.ai/integrations/muse-code/usda-food-search)
- [n8n](https://spiral.ai/integrations/n8n/usda-food-search)
- [Notion](https://spiral.ai/integrations/notion/usda-food-search)
- [OpenClaw](https://spiral.ai/integrations/openclaw/usda-food-search)
- [opencode](https://spiral.ai/integrations/opencode/usda-food-search)
- [Perplexity](https://spiral.ai/integrations/perplexity/usda-food-search)
- [Raycast](https://spiral.ai/integrations/raycast/usda-food-search)
- [VS Code](https://spiral.ai/integrations/vscode/usda-food-search)
- [Windsurf](https://spiral.ai/integrations/windsurf/usda-food-search)
- [Zapier](https://spiral.ai/integrations/zapier/usda-food-search)

## More Codex guides

- [USDA food nutrition details](https://spiral.ai/integrations/codex/usda-food-nutrition-details)
- [USDA foods ranked by nutrient](https://spiral.ai/integrations/codex/usda-foods-ranked-by-nutrient)
- [USDA food categories](https://spiral.ai/integrations/codex/usda-food-categories)
- [USDA nutrient reference](https://spiral.ai/integrations/codex/usda-nutrient-reference)
- [USCG PSIX vessel search](https://spiral.ai/integrations/codex/uscg-psix-vessel-search)
- [Vrbo destination lookup](https://spiral.ai/integrations/codex/vrbo-destination-lookup)

## Questions about USDA food search in Codex

**Can Codex use USDA food search?**

Yes. Add Spiral to Codex as an MCP server, and Codex can find and run USDA food search like any built-in tool.

**How much does USDA food search cost in Codex?**

$0.00873 per call. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your Codex plan is separate.

**Do I need an Alexandria account to use USDA food search in Codex?**

No. Spiral runs USDA food search on its own Alexandria account. You sign in to Spiral once and never paste a key.

**How long does it take to set up USDA food search in Codex?**

About two minutes: add the hosted server, then sign in.

**Does Codex wait while USDA food search runs?**

USDA food search runs in the background. Codex starts the run, checks on it and gives you the json when it's ready.

**How often does USDA update FoodData Central?**

Branded Foods data updates monthly through the API. SR Legacy is a fixed historical reference whose final release was April 2018.

**What does Foundation Foods cover?**

Foundation Foods covers commodity and minimally processed food samples. Its metadata helps explain variation between analyzed samples.

**Does USDA use one category system for every food?**

No. Each FoodData Central data type uses a categorization system developed for its own purpose, so category labels should be interpreted within that data type.

**Can I find a packaged food by its barcode?**

FoodData Central supports searching by GTIN as well as food name. It also supports NDB numbers and FNDDS food codes for the relevant data types.

**What information can I inspect behind a nutrient value?**

A food record can include data points, minimum, maximum, median, derivation details, and portions. Which details are available depends on the selected record.

