LoongSuite GenAI Examples

July 3, 2026 · View on GitHub

Multi-module examples for otel-util-genai manual instrumentation (OTel GenAI Semantic Conventions v1.41.1).

ModuleDescriptionPort
example-commonShared OTel/GenAI config and voice telemetry helpers
basic-exampleREST API covering all well-known gen_ai.operation.name values8080
asr-exampleWebSocket ASR → LLM → TTS voice assistant8080

Prerequisites

  • Java 17+
  • Maven 3.8+
  • DashScope API Key (China North 2 / Beijing): Get API Key

Configuration (local demo)

Edit placeholders in each module's src/main/resources/application.yml (<your-dashscope-api-key>, <your-license-key>, <your-workspace-id>, etc.). Do not commit real API keys.

Default DashScope settings (application.yml)

Property / envDefaultDescription
genai.api-key<your-dashscope-api-key>DashScope API Key
genai.base-urlhttps://dashscope.aliyuncs.com/compatible-mode/v1Beijing OpenAI-compatible endpoint
genai.modelqwen-plusLLM Chat
dashscope.asr.modelfun-asr-realtimeReal-time ASR
dashscope.tts.modelcosyvoice-v3-plusReal-time TTS
dashscope.tts.voicelonganyangv3 system voice

Build

# From repo root
mvn install -DskipTests
mvn -pl examples/example-common,examples/basic-example,examples/asr-example -am compile

basic-example (REST)

Demonstrates chat, embeddings, execute_tool, invoke_agent, invoke_workflow, retrieval, create_agent.

# Edit genai.api-key and CMS placeholders in src/main/resources/application.yml

cd examples/basic-example
mvn spring-boot:run
curl -X POST http://localhost:8080/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "What is OpenTelemetry?"}'

See basic-example/README.md for all endpoints.

asr-example (WebSocket voice)

End-to-end voice turn with GenAI semconv:

websocket.session
└─ invoke_workflow voice_assistant_turn
   ├─ generate_content fun-asr-realtime   # ASR (InferenceInvocation)
   ├─ chat qwen-plus                      # intent + reply
   ├─ execute_tool get_weather            # weather intent only
   └─ generate_content cosyvoice-v3-plus  # TTS + gen_ai.output.type=speech
# Edit genai.api-key and CMS placeholders in src/main/resources/application.yml

cd examples/asr-example && mvn spring-boot:run

For WebSocket protocol, test client, and sample utterances, see asr-example/README.md.

# In another terminal: send 16 kHz mono WAV
pip install websocket-client
python examples/asr-example/scripts/ws_voice_client.py your-16k-mono.wav

Connect: ws://localhost:8080/ws/asr → binary PCM → text END → receive JSON + MP3.

CMS / OTLP

application.yml keeps full OTLP defaults with placeholders. Replace them with your CMS values in the CMS console.

Project layout

examples/
├── pom.xml                 # aggregator
├── example-common/         # GenAiConfig, GenAiOperations, VoiceSessionTelemetry, ...
├── basic-example/          # REST Spring Boot app
└── asr-example/            # WebSocket voice Spring Boot app