Skip to main content

Chat Completions API

Send messages and get AI responses for tax research questions.

Endpoint

POST /chat/completions

Base URL: https://integration-api-cf.damp-bar-d133.workers.dev/v2

Authentication

Authorization: Bearer sk_live_YOUR_API_KEY

Request Parameters

ParameterTypeRequiredDescription
modelstringYesMust be "bizora-1.0"
messagesarrayYesArray of message objects
streambooleanNoEnable streaming (default: false)
webSearchbooleanNoEnable web search mode (default: false)
ZeroDataRetentionbooleanNoKeep zero data retention enabled by default. Pass false only if you want to opt out.

Parameter Usage by Platform

Python SDK:

  • Use extra_body={"webSearch": True} for web search mode

JavaScript SDK:

  • Use webSearch: true directly in the request object

HTTP/curl:

  • Include "webSearch": true in the JSON body

Zero Data Retention

Zero data retention is enabled by default. To opt out for a specific request, pass ZeroDataRetention: false in the request body.

response = client.chat.completions.create(
model="bizora-1.0",
messages=[{"role": "human", "content": "What is section 179?"}],
extra_body={"ZeroDataRetention": False}
)

Message Format

Each message has a role and content:

{
"role": "human",
"content": "What is section 179?"
}

Supported roles:

  • human - User messages
  • ai - AI responses (for conversation history)

Multi-Turn Conversation Example

{
"model": "bizora-1.0",
"messages": [
{"role": "human", "content": "What is section 179?"},
{"role": "ai", "content": "Section 179 allows businesses to deduct the full purchase price of qualifying equipment..."},
{"role": "human", "content": "What are the dollar limits?"}
]
}

Basic Examples

Simple Request

import openai

client = openai.OpenAI(
api_key="sk_live_YOUR_API_KEY",
base_url="https://integration-api-cf.damp-bar-d133.workers.dev/v2"
)

response = client.chat.completions.create(
model="bizora-1.0",
messages=[{"role": "human", "content": "What is section 179?"}]
)

print(response.choices[0].message.content)
# Stream responses in real-time
stream = client.chat.completions.create(
model="bizora-1.0",
messages=[{"role": "human", "content": "What is section 179?"}],
stream=True
)

for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)

Web Search Mode

# Enable web search for real-time internet-based answers
response = client.chat.completions.create(
model="bizora-1.0",
messages=[{"role": "human", "content": "What are the latest tax law changes?"}],
extra_body={"webSearch": True}
)

print(response.choices[0].message.content)

Response Format

Non-Streaming Response

{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "bizora-1.0",
"choices": [{
"index": 0,
"message": {
"role": "ai",
"content": "Section 179 allows businesses to deduct..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 500,
"total_tokens": 510
}
}

Token Usage

The usage object reports token usage for the request:

FieldDescription
prompt_tokensTokens from the user-provided input.
completion_tokensTokens in the final answer returned to the user.
total_tokensTotal tokens across input and output.

Streaming Response

Each chunk contains incremental content:

{
"id": "chatcmpl-abc123",
"object": "chat.completion.chunk",
"created": 1677652288,
"model": "bizora-1.0",
"choices": [{
"index": 0,
"delta": {
"content": "text chunk"
},
"finish_reason": null
}]
}

Next Steps