1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//! # AI SDK Core
//!
//! High-level, ergonomic APIs for building applications with large language models.
//!
//! This crate provides production-ready abstractions over the provider specification
//! layer, offering builder-based APIs, automatic tool execution, structured output
//! generation, and comprehensive error handling.
//!
//! ## Core Features
//!
//! - **Text Generation**: `generate_text()` and `stream_text()` for chat completion
//! - **Tool Execution**: Automatic multi-step tool calling with custom functions
//! - **Embeddings**: `embed()` and `embed_many()` for semantic vector generation
//! - **Structured Output**: `generate_object()` for schema-validated JSON
//! - **Middleware**: Extensible hooks for logging, caching, and custom behavior
//! - **Multi-Provider**: Registry system for managing multiple provider configurations
//!
//! ## Example: Text Generation
//!
//! Generate text using a simple builder pattern with provider-agnostic configuration:
//!
//! ```rust,ignore
//! use ai_sdk_core::generate_text;
//! use ai_sdk_openai::openai;
//!
//! let result = generate_text()
//! .model(openai("gpt-4").api_key(api_key))
//! .prompt("Explain the fundamentals of quantum computing")
//! .temperature(0.7)
//! .max_tokens(500)
//! .execute()
//! .await?;
//!
//! println!("Response: {}", result.text());
//! println!("Tokens used: {}", result.usage.total_tokens);
//! ```
//!
//! ## Example: Tool Calling
//!
//! Implement custom tools that the model can call during generation. The framework
//! handles the execution loop automatically:
//!
//! ```rust,ignore
//! use ai_sdk_core::{generate_text, Tool, ToolContext};
//! use ai_sdk_openai::openai;
//! use async_trait::async_trait;
//! use std::sync::Arc;
//!
//! struct WeatherTool;
//!
//! #[async_trait]
//! impl Tool for WeatherTool {
//! fn name(&self) -> &str { "get_weather" }
//!
//! fn description(&self) -> &str {
//! "Retrieves current weather conditions for a specified location"
//! }
//!
//! fn input_schema(&self) -> serde_json::Value {
//! serde_json::json!({
//! "type": "object",
//! "properties": {
//! "location": {
//! "type": "string",
//! "description": "City name or coordinates"
//! }
//! },
//! "required": ["location"]
//! })
//! }
//!
//! async fn execute(&self, input: serde_json::Value, _ctx: &ToolContext)
//! -> Result<serde_json::Value, ai_sdk_core::ToolError> {
//! let location = input["location"].as_str().unwrap_or("unknown");
//! Ok(serde_json::json!({
//! "location": location,
//! "temperature": 72,
//! "conditions": "sunny"
//! }))
//! }
//! }
//!
//! let result = generate_text()
//! .model(openai("gpt-4").api_key(api_key))
//! .prompt("What's the weather like in Tokyo?")
//! .tools(vec![Arc::new(WeatherTool)])
//! .max_steps(5)
//! .execute()
//! .await?;
//! ```
//!
//! ## Example: Streaming
//!
//! Process responses incrementally as they arrive for real-time user feedback:
//!
//! ```rust,ignore
//! use ai_sdk_core::stream_text;
//! use tokio_stream::StreamExt;
//!
//! let result = stream_text()
//! .model(openai("gpt-4").api_key(api_key))
//! .prompt("Write a creative short story about time travel")
//! .temperature(0.9)
//! .execute()
//! .await?;
//!
//! let mut stream = result.into_stream();
//! while let Some(part) = stream.next().await {
//! match part? {
//! TextStreamPart::TextDelta(delta) => print!("{}", delta),
//! TextStreamPart::FinishReason(reason) => {
//! println!("\nFinished: {:?}", reason);
//! }
//! _ => {}
//! }
//! }
//! ```
/// Internal module for embedding functionality
/// Error definitions for the crate.
// mod generate_text;
// mod stream_text;
/// Utility functions for media type detection, file download, and base64 encoding
/// Generate structured objects with schema validation
/// Middleware system for customizing language model behavior
/// Provider registry system for multi-provider management
// Re-export commonly used types from ai-sdk-provider
pub use ;
pub use ;
// Re-export core functionality
pub use ;
pub use ;
pub use RetryPolicy;
pub use ;
pub use ;
pub use ;
pub use ;