Mira API - Chat Completion

In this tutorial we’ll get you up and running with the chat-completion features of the Mira API.

We do not cover here suggested prompts for potential use cases. Check out the prompt library in the Meltwater application for prompt ideas.

Before you start

To run through this tutorial, you will need:

  • Your Meltwater API token
  • Access to the Mira API Beta program

Authentication

You need to provide your API token when you call any Meltwater API endpoint.

You provide the API token as a header called apikey, for example:

curl -X GET \
  --url "https://api.meltwater.com/v3/searches" \
  --header "Accept: application/json" \
  --header "apikey: **********"

For full details take a look at the Authentication page.

Chat completion endpoint

The API supports chat completion in both streaming and non-streaming mode through the POST /v3/assistants/chat endpoint.

Parameters for the endpoint include:

  • user_prompt - The prompt for completion e.g. “What were the top stories for Adidas last week?”
  • stream - true for streaming mode, false for non-streaming mode
  • thread_id - (optional) if not provided the request will start a new conversation thread, if provided the context of the existing thread you reference will be included as context for the chat completion

Non-streaming mode

For non-streaming chat completion, you send a request to the POST /v3/assistants/chat endpoint.

curl -X POST \
  --url "https://api.meltwater.com/v3/assistants/chat" \
  --header "Accept: application/json" \
  --header "apikey: **********" \
  --data '{
	"user_prompt": "What is going on in the news with fast fashion in the last 7 days?",
	"stream": false
}'

If the request is successful you will see a response similar to below, with the response content itself in Markdown

Example response:

{
	"messages": [
		"1. **Shein Faces Backlash Amid Pop-Up Store Launch in Dijon**\n   - Summary: Shein's pop-up store in Dijon attracted hundreds of customers but also faced protests accusing the brand of exploitation and environmental harm. Critics tagged the store with messages like \"Shein kills\" and \"pollution,\" highlighting the controversies surrounding ultra-fast fashion[^14][^15].\n\n2. **France Targets Ultra-Fast Fashion with New Climate Bill**\n   - Summary: France has introduced amendments to its climate bill, imposing penalties on ultra-fast fashion brands like Shein and Temu. The law aims to curb hyperproduction and promote sustainability, marking a significant regulatory step in the global fight against disposable fashion[^25][^26][^27].\n\n3. **Sustainability in Fashion: Shein's Climate Goals Under Scrutiny**\n   - Summary: Shein's climate goals, validated by the Science Based Targets initiative, have been criticized as greenwashing. Despite pledges to cut emissions and adopt renewable energy, the brand's reliance on polyester and allegations of unethical practices raise doubts about its commitment to sustainability[^22][^23].\n\n4. **Comptoir des Cotonniers and Princesse Tam Tam Seek Judicial Recovery**\n   - Summary: French fashion brands Comptoir des Cotonniers and Princesse Tam Tam have filed for judicial recovery due to financial struggles. The brands, owned by Fast Retailing, have faced challenges from mid-range fashion competition and market shifts[^17][^18][^19].\n\n5. **Simon Cracker Highlights Upcycled Fashion at Milan Fashion Week**\n   - Summary: Designer Simon Cracker showcased a collection of upcycled garments at Milan Fashion Week, emphasizing sustainability and creative reuse. The event highlighted the growing trend of eco-conscious design in the fashion industry[^21].\n\n6. **Luxury Resale Market Grows Amid Tariff Challenges**\n   - Summary: The U.S. luxury resale market is projected to grow significantly, driven by rising tariffs on new luxury goods. Consumers are increasingly turning to secondhand options, boosting the market's value and sustainability efforts[^6].\n\n7. **Alina Basics Revives Polynesian Culture Through Fashion**\n   - Summary: Alina Basics, a Polynesian clothing brand, is blending traditional island culture with modern fashion. The brand's designs celebrate heritage while promoting sustainable practices[^7].\n\n8. **JJ's House Launches Sustainable Wedding Guest Dress Collection**\n   - Summary: JJ's House has introduced a sustainable wedding guest dress collection, featuring made-to-order designs that minimize textile waste. The collection aligns with the growing demand for eco-friendly fashion[^4].\n\n9. **India's Showoffff Achieves Revenue Milestone with Brand Refresh**\n   - Summary: Indian fashion brand Showoffff has surpassed ₹200 crore in revenue following a strategic refresh. The brand's focus on inclusive designs and sustainable practices has resonated with young consumers[^2].\n\n10. **Maxzone Introduces India's First Warranty Track Pants**\n    - Summary: Maxzone has launched a line of track pants with a 365-day warranty, challenging the disposable fashion trend. The collection emphasizes durability and sustainability for everyday wear[^8]."
	],
	"thread_id": "684afd4a43dc9fef57f754cb"
}

Currently only a single message will be returned in the messages field.

The thread_id field returned allows you to continue the conversation. So for example, you could ask a follow-up question for more details:

curl -X POST \
  --url "https://api.meltwater.com/v3/assistants/chat" \
  --header "Accept: application/json" \
  --header "apikey: **********" \
  --data '{
	"user_prompt": "Which story had the highest reach?",
	"stream": false,
    "thread_id": "684afd4a43dc9fef57f754cb"
}'

Note that in non-streaming mode, the API will wait for up to 300 seconds for the chat response to be completed by the system. If the response exceeds 300 seconds the API will return a 504 status code and an error message.

Streaming mode

For chat completion in streaming mode you simply set the streaming field to true in your request to the POST /v3/assistants/chat endpoint.

curl -X POST \
  --url "https://api.meltwater.com/v3/assistants/chat" \
  --header "Accept: application/json" \
  --header "apikey: **********" \
  --data '{
	"user_prompt": "What is going on in the news with fast fashion in the last 7 days?",
	"stream": true
}'

The API will respond by streaming server-side events, similar to the following:

data: {"id":"chatcmpl-43d3c1b9-08a4-4613-b42e-544560628814","object":"chat.completion.chunk","created":1749745452,"choices":[{"index":0,"delta":{"role":"assistant","content":"Analy"}}]}

data: {"id":"chatcmpl-43d3c1b9-08a4-4613-b42e-544560628814","object":"chat.completion.chunk","created":1749745452,"choices":[{"index":0,"delta":{"content":"zing"}}]}

....

data: [DONE]```

The [DONE] event can be used to detect when the response stream has been completed.

Note that for streaming mode the Thread ID is returned as a response header called Thread-Id.

Rate limits

Calls are limited to 100 requests per minute.

Endpoint specification