wankai123 commented on code in PR #13745:
URL: https://github.com/apache/skywalking/pull/13745#discussion_r2973324766


##########
docs/en/setup/service-agent/virtual-genai.md:
##########
@@ -0,0 +1,63 @@
+# Virtual GenAI
+
+Virtual GenAI represents the Generative AI service nodes detected by [server 
agents' plugins](server-agents.md). The performance
+metrics of the GenAI operations are from the GenAI client-side perspective.
+
+For example, a Spring AI plugin in the Java agent could detect the latency of 
a chat completion request.
+As a result, SkyWalking would show traffic, latency, success rate, token usage 
(input/output), and estimated cost in the GenAI dashboard.
+
+## Span Contract
+
+The GenAI operation span should have the following properties:
+- It is an **Exit** span
+- **Span's layer == GENAI**
+- Tag key = `gen_ai.provider.name`, value = The Generative AI provider, e.g. 
openai, anthropic, ollama
+- Tag key = `gen_ai.response.model`, value = The name of the GenAI model, e.g. 
gpt-4o, claude-3-5-sonnet
+- Tag key = `gen_ai.usage.input_tokens`, value = The number of tokens used in 
the GenAI input (prompt)
+- Tag key = `gen_ai.usage.output_tokens`, value = The number of tokens used in 
the GenAI response (completion)
+- Tag key = `gen_ai.server.time_to_first_token`, value = The duration in 
milliseconds until the first token is received (streaming requests only)
+- If the GenAI service is a remote API (e.g. OpenAI), the span's peer should 
be the network address (IP or domain) of the GenAI server.
+
+## Provider Configuration
+
+SkyWalking uses `gen-ai-config.yml` to map model names to providers and 
configure cost estimation.
+
+When the `gen_ai.provider.name` tag is present in the span, it is used 
directly. Otherwise, SkyWalking matches the model name
+against `prefix-match` rules to identify the provider. For example, a model 
name starting with `gpt` is mapped to `openai`.
+
+To configure cost estimation, add `models` with pricing under the provider:
+
+yaml
+```

Review Comment:
   ```suggestion
   ```yaml
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to