publishers
integration
integrate your application to mosaic
Overview
This guide will walk you through the process of integrating Mosaic's API into your AI model or application. By following these steps, you'll be able to serve contextually relevant ads to your users and monetize your AI application.
Prerequisites
Before you begin, you'll need:
A Mosaic account with API access
Your unique API key for each AI model
Basic knowledge of making HTTP requests from your backend
Integration Steps
Step 1: Obtain API Key
Sign-up for a Mosaic account: HERE Each model in your ecosystem should have its own API key.
Step 2: Send Keywords and Context
Your integration should extract and send relevant keywords and user context from each conversation to the Mosaic API.
Step 3: Make API Calls
When appropriate in your application flow, make a call to the /api/fetch-ads
endpoint with the conversation context and extracted keywords.
Step 4: Display Advertisements
Use the campaign_markdown
field from the response to display the advertisement in your application. This field contains ready-to-use markdown with proper tracking links.
Step 5: Implement Error Handling
Implement proper error handling to gracefully manage cases where no ads are available or API calls fail.
Testing Your Integration
To test your integration:
Make test API calls with the required parameters
Verify that ads are displayed correctly in your application
Test the click tracking by clicking on ads and verifying redirects
Check your Mosaic dashboard to confirm impressions and clicks are being recorded
Next Steps
After completing the basic integration:
Review the Best Practices guide
Analyze performance data in your Mosaic dashboard