How to Call a Model Studio Agent API for Release Notes
Your sprint review is in an hour, and someone still has to turn 40 merged tickets into release notes people will actually read. This guide sets up a Model Studio agent API workflow that writes the first draft. You create an agent application in Alibaba Cloud Model Studio, publish it, and call it from a CI step with the DashScope SDK. At the end, a pipeline run produces a Markdown draft and logs the tokens it used.
Create the agent application in Alibaba Cloud Model Studio
In the Model Studio console, open Application Management, click + Create Application, then click Create Now on the Agent Application tab. Pick a model from the drop-down (the agent application docs use Qwen-Plus as the example) and fill in the System prompt. That field sets the role, output format and constraints, so the rules live in one place instead of in every request.
You write sprint release notes for a software team.
Input: merged tickets, one per line, as '<ID> <title>'.
Output: Markdown with three sections: New, Improved, Fixed.
Rules: one bullet per ticket, plain language a customer can follow,
keep the ticket ID in brackets, never invent a ticket or a feature,
and put anything unclear under 'Needs review'.
Test it in the conversation box on the left with a few fake tickets before you go on. The prompt is the part you will tune most, and the console is the cheapest place to do it.
Publish it and copy the Model Studio app ID
Click Publish in the upper-right corner, then Confirm Publish. The docs are blunt about this: an unpublished application cannot be called.
Next, copy the Model Studio app ID from the application card on the Application Management page. This is the app_id the SDK wants. If you don't have an API key yet, create one now. Model Studio shows a new key's plaintext only once, per its June 2026 key storage notice, so paste it straight into your CI secret store.
Install the DashScope SDK and set the key
pip install -U dashscope
export DASHSCOPE_API_KEY='<your-api-key>'
export APP_ID='<your-app-id>'
The SDK reads nothing automatically here: the script below passes the key explicitly from DASHSCOPE_API_KEY, which keeps it out of your code and your repo.
Call the Model Studio agent API from Python
This is the DashScope application call, following the pattern in the application calling guide. Save it as draft_notes.py.
import os
import sys
from http import HTTPStatus
import dashscope
from dashscope import Application
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
def ask(prompt, session_id=None):
extra = {'session_id': session_id} if session_id else {}
response = Application.call(
api_key=os.getenv('DASHSCOPE_API_KEY'),
app_id=os.environ['APP_ID'],
prompt=prompt,
**extra)
if response.status_code != HTTPStatus.OK:
sys.exit('request_id={} code={} message={}'.format(
response.request_id, response.status_code, response.message))
for m in (response.usage or {}).get('models', []):
print('{}: input={} output={}'.format(
m['model_id'], m['input_tokens'], m['output_tokens']),
file=sys.stderr)
return response
if __name__ == '__main__':
with open(sys.argv[1]) as f:
tickets = f.read()
first = ask('Draft sprint release notes from these merged tickets:\n' + tickets)
print(first.output.text)
Three details matter. The script points dashscope.base_http_api_url at the international endpoint. It checks status_code before it touches output.text, because a failed call returns request_id, code and message instead of text. And it exits non-zero on failure, so the pipeline stops rather than publishing an empty note.
The success response includes usage.models, a list where each entry has model_id, input_tokens and output_tokens. The script logs them to stderr, so stdout stays clean for the Markdown file. Multiply them by the rates on the Model Studio pricing page to get the cost per sprint.
Refine the draft with a multi-turn session_id
The first response carries output.session_id. Pass it back with your next prompt and the agent remembers the conversation, with the history stored on Alibaba Cloud's side. Multi-turn works for agent applications and dialog workflow applications only. Add this inside the __main__ block:
second = ask('Shorten this to five bullets for the customer newsletter.',
session_id=first.output.session_id)
with open('NEWSLETTER_DRAFT.md', 'w') as f:
f.write(second.output.text)
In this mode prompt is required on every call.
Run it from a CI step
This GitHub Actions job collects commit subjects since the sprint started (assuming squash merges, so each subject is a ticket title) and runs the script. The key sits in a repository secret and the app ID in a repository variable.
name: sprint-release-notes
on:
workflow_dispatch:
inputs:
since:
description: 'Tag or commit where the sprint started'
required: true
jobs:
draft-notes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install -U dashscope
- name: Draft release notes
env:
SINCE: ${{ inputs.since }}
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
APP_ID: ${{ vars.MODEL_STUDIO_APP_ID }}
run: |
git log "$SINCE"..HEAD --pretty=format:'%s' > tickets.txt
python draft_notes.py tickets.txt > RELEASE_NOTES_DRAFT.md
- uses: actions/upload-artifact@v4
with:
name: release-notes-draft
path: RELEASE_NOTES_DRAFT.md
The input goes through an environment variable instead of straight into the shell command, so a odd tag name can't inject commands. The draft lands as a build artifact for a human to skim.
Gotchas
- Publish first. Calling an unpublished application fails, so publish before the first pipeline run.
messagesbeatssession_id. If you send both,messageswins. Managing history yourself withmessagesneeds dashscope 1.20.14 or later.- Check the endpoint for production. The code uses the international endpoint from the calling guide. Alibaba's June 2026 notice recommends a workspace-dedicated domain (
<workspace-id>.<region>.maas.aliyuncs.com) for better throughput. The address is on the Workspace Details page, so confirm the exact base URL format in the docs before you switch. - The agent only knows what you send. Keep the "never invent" rule in the system prompt and have a person read the draft before it ships.
A draft that fails loudly and logs its own token bill is something you can run every sprint without anyone babysitting it, and that is the difference between a demo and a production step.