Function Calling & Structured JSON Schema on API Store Hub

Guarantee 100% valid JSON matching Zod/JSON Schema (strict: true) for direct ingestion into databases and business APIs.

Ready to ship production AI with one unified API key, VND billing, and multi-provider failover on API Store Hub?

Function Calling & Structured JSON Schema on API Store Hub visual architecture diagram — API Store Hub
Function Calling & Structured JSON Schema on API Store Hub · Base URL https://apistorehub.com · Key prefix sk-ash-

Install command

LanguageTypeScript
RuntimeNode.js 20+ / Python 3.10+, OpenAI & Anthropic SDK
ProtocolOpenAI Compatible (/v1/chat/completions) & Anthropic (/v1/messages)
Install commandnpm install openai zod

3-step quickstart setup

  1. Create an API key on API Store Hub: Sign in to the API Store Hub console, generate a key with prefix sk-ash-, and optionally attach daily or monthly spend caps.
  2. Install SDK & set Base URL: Install the official package and configure environment variables pointing to https://apistorehub.com for /v1/messages.
  3. Run inference with streaming & retry: Invoke gpt-6.2-sol with explicit timeout and jittered retries; every request logs tokens, TTFT, and exact cost.

Production-ready code sample

TypeScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://apistorehub.com/v1", apiKey: process.env.API_KEY });

const res = await client.chat.completions.create({
  model: "gpt-6.2-sol",
  messages: [{ role: "user", content: "Extract order: 2 keyboards at 450000 VND for Minh." }],
  response_format: {
    type: "json_schema",
    json_schema: {
      name: "order_extract",
      strict: true,
      schema: {
        type: "object",
        properties: {
          customer: { type: "string" },
          item: { type: "string" },
          qty: { type: "integer" },
          unit_price_vnd: { type: "integer" }
        },
        required: ["customer", "item", "qty", "unit_price_vnd"],
        additionalProperties: false
      }
    }
  }
});
console.log(JSON.parse(res.choices[0].message.content || "{}"));

cURL

curl https://apistorehub.com/v1/chat/completions \
  -H "Authorization: Bearer sk-ash-your_key" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6.2-sol","response_format":{"type":"json_object"},"messages":[{"role":"system","content":"Return JSON only."},{"role":"user","content":"Extract city from: Giao hang tai Da Nang"}]}'

Recommended models with live pricing

ModelToken priceContext & Endpoint
GPT 6.2 Sol6,700 ST / 1M tokens1.1M
Claude Sonnet 5.57,700 ST / 1M tokens1M
Gemini 4 Neon20,400 ST / 1M tokens2M

Production hardening checklist

  • Always specify additionalProperties: false and list every property in required on nested objects whenever strict: true is enabled.
  • Enable stream=true for long completions (> 500 tokens) to keep connections responsive and minimize time-to-first-token (TTFT).
  • Never hard-code API keys in client bundles; load them from server environment variables and rotate keys periodically in API Store Hub.
  • Configure exponential backoff with jitter for HTTP 429/502/529 and keep a secondary fallback model on the exact same API key.

Frequently asked questions

Does integrating Function Calling & Structured JSON with API Store Hub require rewriting existing calls?
No. API Store Hub preserves native OpenAI (https://apistorehub.com/v1) and Anthropic Messages (https://apistorehub.com/v1/messages) schemas—just update the Base URL and sk-ash- API key.
Can one API key handle streaming, function calling, and embeddings?
Yes. A single API Store Hub key works across all 187 models, including SSE streaming, strict JSON Schema outputs, tool calling, and embeddings.
How are billing and rate limits controlled?
Every request is metered transparently by token or request in the API Store Hub console, never overdrafts your balance, and supports per-key spend caps.