Skip to main content
Neon’s Context.dev template includes web search and scraping, with optional Answers, Brand Retrieval, and News Search routes. Extend the generated function to call any other Context API.

Prerequisites

  • A Neon project and a local application
  • A Context.dev secret API key from the dashboard.
  • The current Neon CLI, which includes neon functions new
If your CLI does not recognize the registry commands, update it:
From your application root, link the project and branch you want to use:

Create the function

Run this from your application root:
This creates functions/contextdev/index.ts and adds it to neon.ts. The default routes are /web-search and /web-scrape. To include all five routes, use this command instead when creating the function:

Configure authentication

Set these values in an uncommitted .env.local file:
Generate CONTEXT_FUNCTION_TOKEN with openssl rand -hex 32. It must be at least 32 characters.
The API key lets the function call Context.dev; the caller token controls access to your function. Keep both server-side and add .env.local to .gitignore.

Run and call the function

Start the function locally:
In a second terminal, set CONTEXT_FUNCTION_TOKEN to the same caller token from .env.local, then send a request:
The response contains results with source URLs. Calls use your Context.dev credits.

Deploy the function

Review neon.ts, then deploy to the linked branch with both secrets:
This applies all services declared in neon.ts to the linked branch. Replace http://localhost:3001 in the request above with the printed function URL, keeping /web-search and the bearer header.

Available routes

See Neon’s route documentation for available operations and request parameters. To add other Context APIs, use the API reference.

Troubleshooting