1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3pub mod capabilities;
20pub mod citizen;
22pub mod clock;
24pub mod codec_openai;
26pub mod content_id;
28pub mod ids;
30pub mod install;
32pub mod manifest;
34pub mod objects;
36pub mod ops;
38mod ops_admin;
39pub mod plan;
41pub mod routes;
43pub mod runtime;
45pub mod server;
47pub mod storage;
49pub mod translate;
51
52pub use capabilities::{
53 AI_RUNNER_CACHE_CAPABILITY, NETWORK_CAPABILITY, OPENAI_GATEWAY_ADMIN_CAPABILITY,
54 OPENAI_GATEWAY_FEDERATE_CAPABILITY, OPENAI_GATEWAY_PLAN_CAPABILITY,
55 OPENAI_GATEWAY_PLAN_REMOTE_CAPABILITY, OPENAI_GATEWAY_SERVE_CAPABILITY,
56 OPENAI_GATEWAY_TOOLS_CAPABILITY, WEBHOOK_SERVE_CAPABILITY, ai_runner_cache_capability,
57 network_capability, openai_gateway_admin_capability, openai_gateway_federate_capability,
58 openai_gateway_plan_capability, openai_gateway_plan_remote_capability,
59 openai_gateway_serve_capabilities, openai_gateway_serve_capability,
60 openai_gateway_tools_capability, require_openai_gateway_serve_capabilities,
61 webhook_serve_capability,
62};
63#[allow(deprecated)]
64pub use clock::{DeterministicGatewayClock, GatewayClock, SystemGatewayClock};
65pub use codec_openai::{
66 ChatTranscript, GatewayEventData, OpenAiCodec, OpenAiCodecOptions, OpenAiRequestOptions,
67 OpenAiSseSurface, StreamSink, decode_openai_request, decode_openai_response,
68 encode_gateway_events_sse, encode_openai_request, encode_openai_response,
69 encode_openai_responses_response, gateway_event_data_from_packet, gateway_event_data_kind,
70 gateway_event_data_packets, openai_codec_symbol,
71};
72pub use content_id::{
73 VOLATILE_REQUEST_FIELDS, content_id_for_expr, normalize_request_expr, request_content_id,
74 request_expr_content_id,
75};
76pub use ids::GatewayIdGenerator;
77pub use install::install_openai_gateway_lib;
78pub use manifest::{OpenAiGatewayLib, manifest_name};
79pub use objects::{
80 GATEWAY_EVENT_OBJECT, GATEWAY_REQUEST_OBJECT, GATEWAY_RESPONSE_OBJECT, GATEWAY_RUN_OBJECT,
81 GatewayEvent, GatewayRequest, GatewayResponse, GatewayResponseValue, GatewayRun,
82 content_id_expr, content_id_hex,
83};
84pub use ops::{
85 OpenAiGatewayFunction, cache_stats_symbol, capability_report_symbol, events_symbol,
86 fabric_symbol, health_symbol, key_add_symbol, key_list_symbol, model_health_symbol,
87 models_symbol, plan_check_symbol, plan_combinators_symbol, plan_explain_symbol,
88 plan_parse_symbol, plan_run_symbol, run_get_symbol, runs_symbol, serve_symbol,
89 storage_stats_symbol,
90};
91pub use plan::{
92 BackendDescriptor, PlanCombinator, PlanEvalEvent, PlanEvalReport, PlanLimits, check_plan,
93 check_plan_with_limits, eval_plan, eval_plan_report, eval_plan_report_with_cache,
94 eval_plan_report_with_cache_and_runners, eval_plan_report_with_cache_runners_and_federation,
95 eval_plan_report_with_federation, explain_plan, parse_plan, plan_combinators,
96 plan_combinators_expr, plan_symbol, provider_prefixes, resolve_atom_address,
97};
98pub use routes::admin::{
99 ADMIN_CACHE_STATS_PATH, ADMIN_CAPABILITY_REPORT_PATH, ADMIN_EVENTS_PATH,
100 ADMIN_MODEL_HEALTH_PATH, ADMIN_RUN_RETRIEVAL_PREFIX, ADMIN_RUN_RETRIEVAL_ROUTE,
101 ADMIN_RUNS_PATH, ADMIN_STORAGE_STATS_PATH,
102};
103pub use routes::audio::{
104 AUDIO_SPEECH_PATH, AUDIO_TRANSCRIPTIONS_PATH, handle_audio_speech, handle_audio_transcriptions,
105};
106pub use routes::batches::{
107 BATCH_CANCEL_ROUTE, BATCH_RETRIEVAL_PREFIX, BATCH_RETRIEVAL_ROUTE, BATCHES_PATH,
108 handle_batch_cancel, handle_batch_retrieval, handle_batches, retrieve_batch,
109};
110pub use routes::chat_completions::{
111 CHAT_COMPLETIONS_PATH, ChatCompletionExecution, execute_chat_completion_request,
112 execute_chat_completion_request_with_runners,
113 execute_chat_completion_request_with_runners_and_federation, handle_chat_completions,
114};
115pub use routes::embeddings::{
116 EMBEDDINGS_PATH, EmbeddingExecution, EmbeddingIdGenerators, TENSOR_F64_SMALL_EMBEDDING_MODEL,
117 execute_embedding_request, handle_embeddings,
118};
119pub use routes::files::{
120 FILE_RETRIEVAL_PREFIX, FILE_RETRIEVAL_ROUTE, FILES_PATH, handle_file_retrieval, handle_files,
121 retrieve_file,
122};
123pub use routes::health::{HEALTH_BODY, HEALTH_PATH, health_response};
124pub use routes::images::{IMAGES_GENERATIONS_PATH, handle_image_generations};
125pub use routes::models::{
126 MODELS_PATH, ModelCatalog, OpenAiModel, models_response, models_response_for_catalog,
127 models_response_for_runner_args,
128};
129pub use routes::replay::{
130 RESPONSE_EVENTS_ROUTE, RESPONSE_EVENTS_SUFFIX, RESPONSE_SIM_ROUTE, RESPONSE_SIM_SUFFIX,
131 SIM_EXTENSION_CAPABILITY, SIM_FORK_PATH, SIM_INSPECTION_CAPABILITY, SIM_REPLAY_PATH,
132 handle_response_events, handle_response_sim, handle_sim_fork, handle_sim_replay,
133 response_events, response_sim,
134};
135pub use routes::responses::{
136 RESPONSE_RETRIEVAL_PREFIX, RESPONSE_RETRIEVAL_ROUTE, RESPONSES_PATH, ResponseExecution,
137 ResponseIdGenerators, ResponseRuntimeTargets, execute_response_request,
138 execute_response_request_with_cache, execute_response_request_with_cache_and_runners,
139 execute_response_request_with_cache_runners_and_federation,
140 execute_response_request_with_runners, handle_response_retrieval, handle_responses,
141 retrieve_response,
142};
143pub use routes::threads::{
144 THREAD_MESSAGES_ROUTE, THREAD_RETRIEVAL_PREFIX, THREAD_RETRIEVAL_ROUTE, THREADS_PATH,
145 handle_thread_get, handle_thread_post, handle_threads, list_messages, retrieve_thread,
146};
147pub use routes::vector_stores::{
148 VECTOR_STORE_SEARCH_PREFIX, VECTOR_STORE_SEARCH_ROUTE, VECTOR_STORE_SEARCH_SUFFIX,
149 VECTOR_STORES_PATH, handle_vector_store_search, handle_vector_stores,
150};
151pub use runtime::{
152 OPENAI_GATEWAY_KEY_OBJECT, OpenAiFederatedGateway, OpenAiFederation, OpenAiFederationPolicy,
153 OpenAiGatewayFabric, OpenAiGatewayKey, OpenAiKeyTable, OpenAiPlanCache, OpenAiRunnerRegistry,
154 PlanCacheKey, PlanCacheMode, PlanCacheWriteTarget, ToolLoopConfig, global_openai_key_table,
155 key_hash, redacted_gateway_request, run_tool_loop_with_cache, run_tool_loop_with_registry,
156};
157pub use server::{
158 GatewayRouteState, GatewayRoutes, GatewayRoutesValue, configure_routes,
159 configure_routes_with_state,
160};
161pub use sim_lib_server::{DeterministicWallClock, SystemWallClock, WallClock, WallTimestamp};
162pub use storage::{
163 GATEWAY_BATCH_KIND, GATEWAY_FILE_KIND, GATEWAY_THREAD_KIND, GATEWAY_THREAD_MESSAGE_KIND,
164 GATEWAY_VECTOR_STORE_ITEM_KIND, GATEWAY_VECTOR_STORE_KIND, GatewayBatch, GatewayBatchCounts,
165 GatewayBatchStatus, GatewayFile, GatewayFileStorageRef, GatewayResponseObjectStore,
166 GatewayStateStore, GatewayStore, GatewayThread, GatewayThreadMessage, GatewayVectorStore,
167 GatewayVectorStoreItem, MemoryGatewayStore, StoredGatewayResponse, TableGatewayStore,
168};
169pub use translate::tools::{
170 OpenAiTool, OpenAiToolCall, OpenAiToolRegistry, OpenAiToolResult, openai_name_to_symbol,
171 symbol_from_text,
172};
173
174pub static RECIPES: sim_cookbook::EmbeddedDir =
176 include!(concat!(env!("OUT_DIR"), "/cookbook_recipes.rs"));
177
178#[cfg(test)]
179mod tests;