Implementing Maitai into your application requires minimal code changes.
Copy
Ask AI
import maitaimaitai_client = maitai.MaitaiAsync()messages = [ {"role": "system", "content": "You are a helpful ordering assistant..."}, {"role": "user", "content": "Generate a response to the customer..."},]response = await maitai_client.chat.completions.create( messages=messages, model="llama3-70b-8192", # Optional: omit to use your Portal config application="YOUR_APPLICATION", # Groups traffic in the Portal (auto-created on first use) intent="CONVERSATION", # Also called action_type (auto-created on first use) session_id="YOUR_SESSION_ID", # Recommended for grouping requests into sessions metadata={}, # Optional: custom tags for filtering/debugging)
session_id is optional (the SDK will generate one if you omit it), but you’ll get the best Portal experience if you provide a stable session id per user/session.
The full implementation reference can be found here: Chat.
Run your application, make sure it makes at least one chat completion request, then head over to portal.trymaitai.ai and inspect the new Application/Intent resources and requests.