Skip to main content

Frequently Asked Questions

General Questions

What is the ZeroinAI Chat Service API?

The ZeroinAI Chat Service API is a set of RESTful endpoints that allow you to integrate intelligent conversational experiences into your applications. It enables you to create chat sessions, send user messages, receive AI responses, and manage conversation history.

What can I build with the ZeroinAI Chat Service API?

You can build a wide range of conversational applications, including:

  • Customer support chatbots
  • Virtual assistants
  • Interactive product guides
  • Knowledge base search interfaces
  • Educational tutoring systems
  • Interactive documentation
  • And much more!

What programming languages can I use with the API?

The ZeroinAI Chat Service API is language-agnostic. Since it's a standard RESTful API that communicates via HTTP, you can use any programming language that can make HTTP requests, such as JavaScript, Python, Java, Ruby, PHP, C#, Go, and many others.

Authentication and Security

How do I authenticate with the API?

Authentication is done using an API key that you include in the X-API-Key header of your requests. You will receive your unique API key from the ZeroinAI admin team.

Is it safe to include my API key in client-side code?

No, you should never include your API key in client-side code that runs in a user's browser. Instead, you should create a backend proxy server that securely stores your API key and handles communication with the ZeroinAI API. Your client-side code should communicate with your proxy server instead.

How can I secure my integration?

To secure your integration:

  1. Always use HTTPS for all API requests
  2. Store your API key securely on your server, never in client-side code
  3. Implement proper authentication and authorization in your application
  4. Consider rate limiting to prevent abuse
  5. Validate and sanitize all user inputs before sending them to the API

Tokens and Billing

What are tokens and how do they work?

Tokens are the unit of measurement for the computational resources used in processing messages and generating responses. Each chat session has a token limit that determines how many tokens can be used in that conversation. Tokens are consumed when:

  1. Processing user messages
  2. Generating AI responses

How do I know when I'm running out of tokens?

When a chat session is about to run out of tokens, you'll receive a 402 Payment Required error when trying to send a message. At this point, you can add more tokens to the chat session using the PUT /chats/{chat_id}/tokens/ endpoint.

How are tokens calculated?

Token usage is calculated based on:

  • The length and complexity of user messages
  • The length and complexity of AI responses
  • The context from previous messages that needs to be maintained

Is there a way to estimate token usage before sending a message?

Currently, there isn't a built-in way to estimate token usage before sending a message. However, as a general rule, longer and more complex messages will consume more tokens.

API Usage

What's the maximum message length I can send?

There is no hard character limit on message length, but very long messages will consume more tokens. For optimal performance and cost-efficiency, we recommend keeping messages concise and focused.

Can I customize the AI's behavior?

Yes, you can customize the AI's behavior through your chat configuration in the ZeroinAI admin portal. This includes setting custom instructions, defining the AI's personality, and specifying domain-specific knowledge.

How do I handle errors from the API?

The API uses standard HTTP status codes to indicate success or failure:

  • 200 OK: The request was successful
  • 400 Bad Request: The request was malformed
  • 401 Unauthorized: Invalid or missing API key
  • 402 Payment Required: Not enough tokens remaining
  • 404 Not Found: Resource not found
  • 422 Unprocessable Entity: Request validation failed
  • 500 Internal Server Error: Server-side error

Always implement proper error handling in your code to gracefully handle these scenarios.

Is there a rate limit for API requests?

Yes, there are rate limits in place to ensure fair usage and system stability. The specific limits depend on your plan. If you exceed the rate limit, you'll receive a 429 Too Many Requests response. Implement exponential backoff in your code to handle rate limiting gracefully.

Chat Widget

Can I customize the appearance of the chat widget?

Yes, you can customize the appearance of the chat widget through your chat configuration in the ZeroinAI admin portal. This includes setting the primary color, logo, header text, and other visual elements.

Can I use my own UI instead of the provided chat widget?

Absolutely! While we provide a ready-to-use chat widget, you can build your own custom UI using the API directly. Check out our examples for implementation ideas.

How do I position the chat widget on my website?

You can control the position of the chat widget using the data-position attribute in the embed script:

<script 
src="https://chat-service.agent.binj.com/embed.js"
data-chat-id="YOUR_CHAT_ID"
data-position="corner"
async
></script>

The available positions are:

  • "corner": Places the chat button in the bottom-right corner (default)
  • "center": Places the chat widget in the center of the screen

Troubleshooting

The API returns a 401 Unauthorized error. What should I do?

This typically means your API key is invalid or missing. Check that:

  1. You're including the X-API-Key header in your requests
  2. The API key value is correct and hasn't expired
  3. There are no extra spaces or characters in the API key

I'm getting a 404 Not Found error when trying to send a message. What's wrong?

This usually means the chat ID you're using doesn't exist. This could happen if:

  1. The chat was deleted
  2. The chat ID was typed incorrectly
  3. The chat has expired

Try creating a new chat session with the POST /chats/ endpoint.

The chat widget isn't appearing on my website. How do I fix this?

Check the following:

  1. The embed script is correctly added to your HTML
  2. The data-chat-id attribute contains a valid chat ID
  3. There are no JavaScript errors in your browser console
  4. Your domain is allowed to use the chat widget (check your configuration)

How do I report a bug or request a feature?

For bug reports, feature requests, or other questions, please contact our support team at [email protected].

Additional Resources