openai_ergonomic/
semantic_conventions.rs

1//! OpenTelemetry Semantic Conventions for Generative AI
2//!
3//! This module defines constants for OpenTelemetry semantic conventions
4//! for generative AI operations, following the official specification:
5//! <https://opentelemetry.io/docs/specs/semconv/gen-ai/>
6//!
7//! We use the official attribute names from the opentelemetry-semantic-conventions
8//! crate and define our own operation values until they are officially available.
9
10// Re-export the official GenAI attribute constants from the crate
11pub use opentelemetry_semantic_conventions::attribute::{
12    GEN_AI_OPERATION_NAME, GEN_AI_REQUEST_MODEL, GEN_AI_SYSTEM,
13};
14
15/// Standard operation names for `OpenAI` APIs
16pub mod operation_names {
17    /// Chat completion operation (`ChatGPT`, `GPT-4`, etc.)
18    pub const CHAT: &str = "chat";
19
20    /// Responses operation (structured outputs API)
21    pub const RESPONSES: &str = "responses";
22
23    /// Create embeddings operation
24    pub const EMBEDDINGS: &str = "embeddings";
25
26    /// Text completion operation (legacy)
27    pub const TEXT_COMPLETION: &str = "text_completion";
28
29    /// Image generation operation (`DALL-E`)
30    pub const IMAGE_GENERATION: &str = "image_generation";
31
32    /// Image edit operation
33    pub const IMAGE_EDIT: &str = "image_edit";
34
35    /// Image variation operation
36    pub const IMAGE_VARIATION: &str = "image_variation";
37
38    /// Audio transcription operation (`Whisper`)
39    pub const AUDIO_TRANSCRIPTION: &str = "audio_transcription";
40
41    /// Audio translation operation
42    pub const AUDIO_TRANSLATION: &str = "audio_translation";
43
44    /// Text-to-speech operation
45    pub const AUDIO_SPEECH: &str = "audio_speech";
46
47    /// Content moderation operation
48    pub const MODERATION: &str = "moderation";
49
50    /// File upload operation
51    pub const FILE_UPLOAD: &str = "file_upload";
52    /// File retrieve operation
53    pub const FILE_RETRIEVE: &str = "file_retrieve";
54    /// File list operation
55    pub const FILE_LIST: &str = "file_list";
56    /// File delete operation
57    pub const FILE_DELETE: &str = "file_delete";
58    /// File download operation
59    pub const FILE_DOWNLOAD: &str = "file_download";
60
61    /// Assistant create operation
62    pub const ASSISTANT_CREATE: &str = "assistant_create";
63    /// Assistant list operation
64    pub const ASSISTANT_LIST: &str = "assistant_list";
65    /// Assistant retrieve operation
66    pub const ASSISTANT_RETRIEVE: &str = "assistant_retrieve";
67    /// Assistant update operation
68    pub const ASSISTANT_UPDATE: &str = "assistant_update";
69    /// Assistant delete operation
70    pub const ASSISTANT_DELETE: &str = "assistant_delete";
71
72    /// Thread create operation
73    pub const THREAD_CREATE: &str = "thread_create";
74
75    /// Message create operation
76    pub const MESSAGE_CREATE: &str = "message_create";
77    /// Message list operation
78    pub const MESSAGE_LIST: &str = "message_list";
79    /// Message retrieve operation
80    pub const MESSAGE_RETRIEVE: &str = "message_retrieve";
81
82    /// Run create operation
83    pub const RUN_CREATE: &str = "run_create";
84    /// Run list operation
85    pub const RUN_LIST: &str = "run_list";
86    /// Run retrieve operation
87    pub const RUN_RETRIEVE: &str = "run_retrieve";
88    /// Run cancel operation
89    pub const RUN_CANCEL: &str = "run_cancel";
90    /// Run submit tool outputs operation
91    pub const RUN_SUBMIT_TOOL_OUTPUTS: &str = "run_submit_tool_outputs";
92
93    /// Run step list operation
94    pub const RUN_STEP_LIST: &str = "run_step_list";
95    /// Run step retrieve operation
96    pub const RUN_STEP_RETRIEVE: &str = "run_step_retrieve";
97
98    /// Vector store create operation
99    pub const VECTOR_STORE_CREATE: &str = "vector_store_create";
100    /// Vector store list operation
101    pub const VECTOR_STORE_LIST: &str = "vector_store_list";
102    /// Vector store retrieve operation
103    pub const VECTOR_STORE_RETRIEVE: &str = "vector_store_retrieve";
104    /// Vector store update operation
105    pub const VECTOR_STORE_UPDATE: &str = "vector_store_update";
106    /// Vector store delete operation
107    pub const VECTOR_STORE_DELETE: &str = "vector_store_delete";
108    /// Vector store file add operation
109    pub const VECTOR_STORE_FILE_ADD: &str = "vector_store_file_add";
110    /// Vector store file list operation
111    pub const VECTOR_STORE_FILE_LIST: &str = "vector_store_file_list";
112    /// Vector store file retrieve operation
113    pub const VECTOR_STORE_FILE_RETRIEVE: &str = "vector_store_file_retrieve";
114    /// Vector store file delete operation
115    pub const VECTOR_STORE_FILE_DELETE: &str = "vector_store_file_delete";
116    /// Vector store search operation
117    pub const VECTOR_STORE_SEARCH: &str = "vector_store_search";
118
119    /// Upload create operation
120    pub const UPLOAD_CREATE: &str = "upload_create";
121
122    /// Batch create operation
123    pub const BATCH_CREATE: &str = "batch_create";
124    /// Batch list operation
125    pub const BATCH_LIST: &str = "batch_list";
126    /// Batch retrieve operation
127    pub const BATCH_RETRIEVE: &str = "batch_retrieve";
128    /// Batch cancel operation
129    pub const BATCH_CANCEL: &str = "batch_cancel";
130
131    /// Fine-tuning create operation
132    pub const FINE_TUNING_CREATE: &str = "fine_tuning_create";
133    /// Fine-tuning list operation
134    pub const FINE_TUNING_LIST: &str = "fine_tuning_list";
135    /// Fine-tuning retrieve operation
136    pub const FINE_TUNING_RETRIEVE: &str = "fine_tuning_retrieve";
137    /// Fine-tuning cancel operation
138    pub const FINE_TUNING_CANCEL: &str = "fine_tuning_cancel";
139    /// Fine-tuning list events operation
140    pub const FINE_TUNING_LIST_EVENTS: &str = "fine_tuning_list_events";
141    /// Fine-tuning list checkpoints operation
142    pub const FINE_TUNING_LIST_CHECKPOINTS: &str = "fine_tuning_list_checkpoints";
143
144    /// Model list operation
145    pub const MODEL_LIST: &str = "model_list";
146    /// Model retrieve operation
147    pub const MODEL_RETRIEVE: &str = "model_retrieve";
148    /// Model delete operation
149    pub const MODEL_DELETE: &str = "model_delete";
150
151    /// Usage audio speeches operation
152    pub const USAGE_AUDIO_SPEECHES: &str = "usage_audio_speeches";
153    /// Usage audio transcriptions operation
154    pub const USAGE_AUDIO_TRANSCRIPTIONS: &str = "usage_audio_transcriptions";
155    /// Usage code interpreter operation
156    pub const USAGE_CODE_INTERPRETER: &str = "usage_code_interpreter";
157    /// Usage completions operation
158    pub const USAGE_COMPLETIONS: &str = "usage_completions";
159    /// Usage embeddings operation
160    pub const USAGE_EMBEDDINGS: &str = "usage_embeddings";
161    /// Usage images operation
162    pub const USAGE_IMAGES: &str = "usage_images";
163    /// Usage moderations operation
164    pub const USAGE_MODERATIONS: &str = "usage_moderations";
165    /// Usage vector stores operation
166    pub const USAGE_VECTOR_STORES: &str = "usage_vector_stores";
167    /// Usage costs operation
168    pub const USAGE_COSTS: &str = "usage_costs";
169}
170
171/// System/provider name constants
172pub mod systems {
173    /// `OpenAI` as the `GenAI` provider
174    pub const OPENAI: &str = "openai";
175}
176
177/// Output type constants
178pub mod output_types {
179    /// Plain text output
180    pub const TEXT: &str = "text";
181
182    /// JSON structured output
183    pub const JSON: &str = "json";
184
185    /// Image output
186    pub const IMAGE: &str = "image";
187
188    /// Speech/audio output
189    pub const SPEECH: &str = "speech";
190}
191
192/// Service tier constants
193pub mod service_tiers {
194    /// Utilize scale tier credits
195    pub const AUTO: &str = "auto";
196
197    /// Use default scale tier
198    pub const DEFAULT: &str = "default";
199}