Skip to main content
This page collects working patterns you can adapt for production integrations. Use these examples as templates, not as copy-paste production code without review. In production, add proper secret handling, retries, timeouts, and structured logging.

Shared environment variables

Use environment variables so the same examples can run in local, staging, and production environments.

1. Connectivity check with tenant limits

Start every new integration with a simple authenticated read call.
Use this request to verify:
  • The API key is valid
  • The environment configuration is correct
  • Your deployment can reach the API

2. Upload a file document

Use file upload when you already have approved content in PDF, Word, or text format.
If your integration tracks content versions, log the returned document identifier so you can activate, update, or audit it later.

3. Create a text document

Use text documents when your source content already exists as application-managed text.

4. Create a Q&A document

Use Q&A documents for short, deterministic answers to repeated questions.

5. Send a sync chat request

Use sync chat when the caller expects the answer in the same request cycle.
Typical response shape:

6. Send an async chat request and poll for completion

Use async chat when you want non-blocking request handling.
Production polling guidance:
  • Poll on a fixed short interval such as 2-3 seconds
  • Stop when status becomes completed or failed
  • Apply an overall timeout so jobs do not poll forever

7. Submit feedback for a response

Use feedback to send a quality signal after a completed response. Accepted feedback values are good and bad.
Send feedback only after the response is completed and only once per evaluation event in your application workflow.

8. Close a session explicitly

Close a session when the business flow is complete and you do not want the conversation to remain open indefinitely.

9. Read site statistics

Use site statistics to monitor how your integration performs after rollout.

10. Read sessions

Use sessions when you need operational visibility into conversation activity.

11. Minimal JavaScript client

Use a shared helper for request headers, JSON parsing, and error handling.

12. Async polling helper in JavaScript

13. Minimal Python client

14. End-to-end smoke script idea

A minimal smoke flow should:
  1. Validate tenant limits
  2. Upload one small document
  3. Send one sync chat request
  4. Send one async chat request and poll for completion
  5. Submit feedback for a completed request
  6. Read site statistics
Use this as a deploy-time or post-deploy verification sequence in staging before promoting to production.