Skip to main content
Complete these steps only if you selected Weave.

1. Create your account and API key

Register for AdMesh, complete onboarding, and select Weave in your platform’s ad formats. Create an API key in the dashboard.

2. Install the SDKs

Install the frontend SDK:
Install the backend SDK for your stack:

3. Fetch recommendations before calling your LLM

Use the conversation’s sessionId, the original user query, and the message ID used for the backend recommendation request.
For Python, use the Python backend setup.

4. Add the recommendation to your LLM context

When a recommendation is available, pass its title, summary, and exact click_url to your LLM using the template below. Serialize the fields as data; do not insert recommendation content as instructions. If none is returned, generate your normal response.

Canonical Weave Prompt Template

Build serialized_recommendation_data with the title, summary, and Markdown link using Node.js or Python. Verify the generated link preserves click_url exactly. If it changes, retry once; if it still fails, omit the invalid sponsored link and let the frontend fallback handle recommendations. The UI SDK adds the Ad label; do not ask the LLM to add a duplicate label.

5. Wrap your chat and assistant responses

Keep the provider sessionId consistent with your backend. Pass the assistant message ID returned by your backend to WeaveAdFormatContainer.
Render Markdown links as clickable anchors inside the container. Use fallbackFormat="tail" or "product"; the container handles fallback when no woven links are found. Do not also render a standalone AdMeshRecommendations for the same response.

6. Connect streaming events

Call these functions from the corresponding handlers in your chat. Use the same assistant message ID as the container and the same session ID as the provider.

7. Test your integration

  1. Send a query that returns an eligible recommendation and verify the response contains its unchanged tracking link.
  2. Check that the rendered link has an Ad label and works when clicked.
  3. Test a response without woven links; check the configured fallback when an eligible recommendation is available.

Troubleshooting

  • Links are not detected: check that rendered anchors are inside the container and the tracking URL is unchanged.
  • Detection runs too early: dispatch completion only after the final response renders, using matching assistant message and session IDs.
  • No fallback appears: check your API key and query; a fallback still requires an eligible recommendation.