Quickstart — OpenAI function-calling
OpenAI's tools field accepts the same JSON-Schema shape we publish. Bind once, call forever.
import OpenAI from 'openai';
const openai = new OpenAI();
const tools = [{
type: 'function',
function: {
name: 'hex_intel',
description: 'Returns labels + admin + transit + POIs + env signals for an H3 cell.',
parameters: {
type: 'object',
properties: { h3: { type: 'string', pattern: '^8[0-9a-f]{14}$' } },
required: ['h3'],
},
},
}];
const chat = await openai.chat.completions.create({
model: 'gpt-4o-mini',
tools,
messages: [{ role: 'user', content: 'Summarise the cell 8861aacd1bfffff for a real-estate analyst.' }],
});When the model emits a tool_call for hex_intel, call https://api.gridrock.ai/v1/intel/hex/<h3> with your agent bearer token and feed the raw JSON back as the tool result.