Skip to content
中文

Quickstart

Search gives AI applications web search. It returns structured results with a title, a link, extracted content and a relevance score, ready for question answering or for an agent to use.

Prerequisites

You need Bun or Node.js with native fetch, and an API Key for your organization (see API Keys). Set PRAXIS_API_KEY in the server process. The organization needs the deepseek-flash model and a balance.

POST /search/v1/search. query is required and max_results limits the number of results (at most 20). Each result has title, url, content and score.

终端窗口
curl -sS https://api.deepraxis.com/search/v1/search \
-H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" \
-d '{"query": "Cloudflare Workers pricing", "max_results": 3}'

The results array in the response is ordered by relevance; each item looks like {"title": "…", "url": "https://…", "content": "…", "score": 0.87}.

Add a search binding, bindings: [{ "type": "search" }], to a service agent and its codemode can call praxis.search.* (search.create, extract.create, crawl.create, map.create). The script searches once directly, then creates an agent with the search binding and asks it to call search through codemode and give a link. Save it as search-demo.mjs and run node search-demo.mjs.

import assert from "node:assert/strict";
import { setTimeout as delay } from "node:timers/promises";
const { PRAXIS_API_KEY } = process.env;
assert(PRAXIS_API_KEY, "Set PRAXIS_API_KEY in the server process");
const api = "https://api.deepraxis.com";
async function request(path, body) {
const response = await fetch(`${api}${path}`, {
method: body === undefined ? "GET" : "POST",
headers: { Authorization: `Bearer ${PRAXIS_API_KEY}`, "Content-Type": "application/json" },
...(body === undefined ? {} : { body: JSON.stringify(body) }),
signal: AbortSignal.timeout(60_000),
});
const result = await response.json();
if (!response.ok) {
throw new Error(`HTTP ${response.status}; request=${response.headers.get("X-Request-Id")}; ${result.error?.message ?? result.detail ?? ""}`);
}
return result;
}
// 1. Search directly.
const found = await request("/search/v1/search", { query: "Cloudflare Workers pricing", max_results: 3 });
assert(found.results.length > 0, "Expected at least one result");
console.log(found.results.map(({ title, url, score }) => ({ title, url, score })));
// 2. Give an agent the search service with a binding.
const agent = await request("/agent/v1/agents", {
name: "Research assistant", kind: "service", model: "deepseek-flash",
system: "Answer with current information. Look it up with codemode through the platform search service and cite the URL.",
tools: [{
type: "agent_toolset_20260401",
configs: [{ name: "web_search", enabled: false }, { name: "web_fetch", enabled: false }],
}],
bindings: [{ type: "search" }],
});
assert.equal(agent.bindings[0].type, "search");
const session = await request("/agent/v1/sessions", {
agent: { type: "agent", id: agent.id, version: agent.version },
});
await request(`/agent/v1/sessions/${session.id}/events`, {
events: [{ type: "user.message", content: [{ type: "text", text: "Use codemode to call praxis.search.search.create for the Cloudflare Workers pricing page and give me its URL." }] }],
});
// 3. Wait for a reply that is followed by an idle status.
const deadline = Date.now() + 180_000;
let reply = "";
while (Date.now() < deadline && !reply) {
const { data } = await request(`/agent/v1/sessions/${session.id}/events?order=asc&limit=100`);
const last = data.findLastIndex((event) => event.type === "agent.message");
if (last >= 0 && data.slice(last).some((event) => event.type === "session.status_idle")) {
reply = data.filter((event) => event.type === "agent.message")
.flatMap((event) => event.content ?? []).map((block) => block.text ?? "").join("\n");
} else await delay(2000);
}
assert(reply.includes("http"), `Expected a URL in the reply, got: ${reply}`);
console.log({ session: session.id, reply });

Expected: first the title, link and score of three results; at the end the session ID and the agent’s reply, which contains a link taken from the search results. The example disables the native web_search and web_fetch tools so that you can confirm the answer comes through the search binding.

Search binding versus the web_search tool

Both let an agent search the web, but they are different paths:

{type: "search"} bindingNative web_search tool
What it isOpens the whole search service in the agent’s bindingsOne tool in the built-in toolset, enabled by default on new agents
How it is usedThe agent writes code in codemode and calls praxis.search.search.create, extract, crawl and map, with every parameter of the API and room to post-process resultsThe model calls it directly with a query and gets results with citations; you can allow or block domains
Switchenabled on the binding; needs a machine (environment_id must not be null)Enable or disable it by name in the toolset configs
FitsBulk searching, fetching pages, walking a site, or handing results to later codeA quick lookup of current information

If you only want the agent to look things up on the web, the default web_search is enough and no binding is needed. Add the binding when you need the search service’s full API.

When it fails

SymptomWhat to do
HTTP 401Check that PRAXIS_API_KEY is set and belongs to your organization
Creating the agent returns 400 bindings need a machineBindings need a machine; do not set environment_id to null
The agent did not call searchAsk explicitly for codemode and praxis.search.search.create in the prompt, and confirm a codemode tool call appears in the events

Next steps

Billing

Each search call bills a flat rate regardless of which provider served it: basic Billed per call(See the live price), advanced Billed per call(See the live price). Charges draw on the organization balance; see Billing. Failed searches (non-200 or empty results) are not billed. Price changes come with 30 days’ notice.