C
ChowAPI
AI Integrations

ChowAPI + ChatGPT

Build a custom GPT with food lookup, or integrate ChowAPI into your OpenAI-powered app with function calling.

Easiest

Custom GPT: System Prompt

Create a custom GPT in ChatGPT and paste this system prompt. Then add the Actions schema below to give it API access.

You are a nutrition expert assistant powered by ChowAPI. You have access to a database of 1.6M+ foods with 34 nutrients each.

When a user asks about food or nutrition:
1. Use the search_foods action to find the food
2. Present the nutrition data clearly with per-serving and per-100g values
3. Highlight key nutrients relevant to the user's question
4. Note the data_quality score. Mention if it's below 0.7

API Details:
- Base URL: https://api.chowapi.dev/v1
- Auth: Bearer chow_live_YOUR_KEY (in Authorization header)
- All nutrient values are per 100g

Available endpoints:
- GET /v1/search?q={query}&limit={n} - search foods by name
- GET /v1/barcode/{code} - lookup by UPC/EAN barcode
- GET /v1/foods/{id}/nutrients - detailed nutrients with confidence levels

Always cite the confidence level when providing nutrient information.

GPT Actions: OpenAPI Schema

Paste this into your custom GPT's Actions configuration. Set the authentication to “API Key” with Bearer token.

openapi: "3.1.0"
info:
  title: ChowAPI Food Nutrition
  version: "1.0"
  description: Search foods and get nutrition data from 1.6M+ foods.
servers:
  - url: https://api.chowapi.dev/v1
paths:
  /search:
    get:
      operationId: searchFoods
      summary: Search for foods by name
      parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
          description: Search query (e.g., "chicken breast")
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            maximum: 25
      responses:
        "200":
          description: Search results with nutrition data
  /barcode/{code}:
    get:
      operationId: barcodeLookup
      summary: Look up food by barcode
      parameters:
        - name: code
          in: path
          required: true
          schema:
            type: string
          description: UPC-A or EAN-13 barcode
      responses:
        "200":
          description: Food with full nutrition data
  /foods/{id}/nutrients:
    get:
      operationId: getNutrients
      summary: Get detailed nutrients for a food
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: ChowAPI food UUID
      responses:
        "200":
          description: Detailed nutrients with confidence and RDI

OpenAI API: Function Calling

Building with the OpenAI API directly? Here are the function definitions to pass in your functions array.

// OpenAI API function calling definitions

const functions = [
  {
    name: "search_foods",
    description: "Search for foods by name. Returns nutrition data for matching foods.",
    parameters: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Food search query, e.g. 'chicken breast' or 'quaker oatmeal'"
        },
        limit: {
          type: "number",
          description: "Max results (1-25, default 10)"
        }
      },
      required: ["query"]
    }
  },
  {
    name: "barcode_lookup",
    description: "Look up a food by its UPC/EAN barcode. Returns full nutrition data.",
    parameters: {
      type: "object",
      properties: {
        barcode: {
          type: "string",
          description: "UPC-A or EAN-13 barcode (8-14 digits)"
        }
      },
      required: ["barcode"]
    }
  },
  {
    name: "get_nutrients",
    description: "Get detailed nutrient breakdown with confidence levels and %RDI.",
    parameters: {
      type: "object",
      properties: {
        food_id: {
          type: "string",
          description: "ChowAPI food UUID"
        }
      },
      required: ["food_id"]
    }
  }
]