API Reference
AI Chat Completions
OpenAI-compatible endpoint for streaming and conversational tax intelligence.
AI Chat Completions
POST /api/v1/chat/completions
An OpenAI-compatible chat completions endpoint that leverages the full Tax Nigeria cognitive architecture, including grounding against Nigerian tax legislation, context-aware memory, and multilingual conversational capability.
You can drop the Tax Nigeria API directly into the official OpenAI SDK, LangChain, or Vercel AI SDK by pointing the baseURL to https://taxnigeria.ng/api/v1.
Required scope: tax:chat.
Request Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
messages | array | Yes | — | Array of conversation message objects: [{ role: "user", content: "..." }]. |
model | string | No | "gpt-4o-mini" | Model identifier. |
stream | boolean | No | false | Whether to stream back partial chunks as server-sent events (SSE). |
mode | string | No | "ai_tax_queries" | AI persona mode ("ai_tax_queries", "general", "education"). |
language | string | No | "English" | Language response preference ("English", "Pidgin", "Yoruba", "Hausa", "Igbo"). |
conversation_id | string | No | — | Optional conversation ID to persist dialog turns to your Tax Nigeria workspace. |
Code Examples
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TAX_NIGERIA_API_KEY,
baseURL: "https://taxnigeria.ng/api/v1",
});
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "user", content: "What is the penalty for failing to remit PAYE tax to LIRS on time in Lagos State?" }
],
});
console.log(response.choices[0].message.content);Response Example (200 OK)
{
"id": "chatcmpl_98f12a3d4e5b",
"object": "chat.completion",
"created": 1719576400,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Under the Personal Income Tax Act (PITA) Section 33, Consolidated Relief Allowance (CRA) is a statutory tax relief deducted from an individual's gross earned income before taxable income is computed. It is calculated as the higher of ₦200,000 or 1% of gross income, plus 20% of gross income. This significantly reduces the taxable base for all income earners across Nigeria."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 142,
"completion_tokens": 88,
"total_tokens": 230
},
"sources": [
{
"title": "Personal Income Tax Act (PITA) Cap P8 LFN 2004",
"section": "Section 33 - Consolidated Relief Allowance"
}
]
}