> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trymirai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloud

<Tip>
  In this example, we will get a reply to a specific list of messages from a cloud model.
</Tip>

<Tabs>
  <Tab title="Python">
    <Steps>
      <Step title="Create a new project">
        ```sh theme={null}
        uv init demo && cd demo
        ```
      </Step>

      <Step title="Install dependencies">
        ```sh theme={null}
        uv add uzu
        ```
      </Step>

      <Step title="Paste into main.py">
        ```python theme={null}
        import asyncio

        from uzu import ChatConfig, ChatMessage, ChatReplyConfig, Engine, EngineConfig, ReasoningEffort


        async def main() -> None:
            engine_config = EngineConfig.create().with_openai_api_key("OPENAI_API_KEY")
            engine = await Engine.create(engine_config)

            model = await engine.model("gpt-5")
            if model is None:
                raise RuntimeError("Model not found")

            messages = [
                ChatMessage.system().with_reasoning_effort(ReasoningEffort.Low),
                ChatMessage.user().with_text("How LLMs work"),
            ]

            session = await engine.chat(model, ChatConfig.create())
            replies = await session.reply(messages, ChatReplyConfig.create())
            if replies:
                message = replies[0].message
                print(f"Reasoning: {message.reasoning}")
                print(f"Text: {message.text}")


        if __name__ == "__main__":
            asyncio.run(main())
        ```
      </Step>

      <Step title="Run the snippet">
        ```sh theme={null}
        uv run main.py
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Swift">
    <Steps>
      <Step title="Create a new SwiftUI project">
        <img src="https://mintcdn.com/mirai-bded675a/-MIzY7hlOp3HioeZ/images/quick-start/xcode-new-project.png?fit=max&auto=format&n=-MIzY7hlOp3HioeZ&q=85&s=7ef3a6a5ada8fec6d6cfe024e598e278" alt="" width="1430" height="1020" data-path="images/quick-start/xcode-new-project.png" />
      </Step>

      <Step title="Add the SDK">
        Add this package through SPM:

        ```sh theme={null}
        https://github.com/trymirai/uzu.git
        ```
      </Step>

      <Step title="Paste the snippet">
        ```swift theme={null}
        import Uzu

        public func runChatCloud() async throws {
            let engineConfig = EngineConfig.create().withOpenaiApiKey(openaiApiKey: "OPENAI_API_KEY")
            let engine = try await Engine.create(config: engineConfig)
            
            guard let model = try await engine.model(identifier: "Qwen/Qwen3-0.6B") else {
                return
            }
            
            let messages = [
                ChatMessage.system().withReasoningEffort(reasoningEffort: .low),
                ChatMessage.user().withText(text: "How LLMs work")
            ]
            
            let session = try await engine.chat(model: model, config: .create())
            let reply = try await session.reply(input: messages, config: .create())
            guard let message = reply.last?.message else {
                return
            }
            
            print("Reasoning: \(message.reasoning() ?? "empty")")
            print("Text: \(message.text() ?? "empty")")
        }
        ```
      </Step>

      <Step title="Add the snippet call">
        ```swift theme={null}
        var body: some View {
            VStack {
                Text("On-device AI")
            }
            .onAppear() {
                Task {
                    try await runExampleName()
                }
            }
        }
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="TypeScript">
    <Steps>
      <Step title="Make a new project folder">
        ```sh theme={null}
        mkdir demo && cd demo
        ```
      </Step>

      <Step title="Initialize with pnpm">
        ```sh theme={null}
        pnpm init
        ```
      </Step>

      <Step title="Install dependencies">
        ```sh theme={null}
        pnpm add typescript ts-node @types/node -D
        pnpm add @trymirai/uzu
        ```
      </Step>

      <Step title="Initialize a tsconfig.json">
        ```json theme={null}
        {
            "compilerOptions": {
                "target": "es2020",
                "module": "commonjs",
                "moduleResolution": "node",
                "strict": true,
                "esModuleInterop": true,
                "outDir": "dist",
                "types": [
                    "node"
                ]
            },
            "include": [
                "*.ts"
            ]
        }
        ```
      </Step>

      <Step title="Create main.ts">
        ```ts theme={null}
        import { ChatConfig, ChatMessage, ChatReplyConfig, Engine, EngineConfig, ReasoningEffort } from '@trymirai/uzu';

        async function main() {
            let engineConfig = EngineConfig.create().withOpenaiApiKey('OPENAI_API_KEY');
            let engine = await Engine.create(engineConfig);

            let model = await engine.model('gpt-5');
            if (!model) {
                throw new Error('Model not found');
            }

            let messages = [
                ChatMessage.system().withReasoningEffort("Low" as ReasoningEffort),
                ChatMessage.user().withText('How LLMs work')
            ];

            let session = await engine.chat(model, ChatConfig.create());
            let reply = await session.reply(messages, ChatReplyConfig.create());
            let message = reply[0]?.message;
            if (message) {
                console.log('Reasoning: ', message.reasoning);
                console.log('Text: ', message.text);
            }
        }

        main().catch((error) => {
            console.error(error);
        });
        ```
      </Step>

      <Step title="Run the snippet">
        ```sh theme={null}
        pnpm ts-node main.ts
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Rust">
    <Steps>
      <Step title="Create a new project">
        ```sh theme={null}
        cargo new demo && cd demo
        ```
      </Step>

      <Step title="Install dependencies">
        ```sh theme={null}
        cargo add uzu --git https://github.com/trymirai/uzu
        cargo add tokio --features full
        ```
      </Step>

      <Step title="Paste into src/main.rs">
        ```rust theme={null}
        use uzu::{
            engine::{Engine, EngineConfig},
            types::{
                basic::ReasoningEffort,
                session::chat::{ChatConfig, ChatMessage, ChatReplyConfig},
            },
        };

        #[tokio::main]
        async fn main() -> Result<(), Box<dyn std::error::Error>> {
            let engine_config = EngineConfig::default().with_openai_api_key("OPENAI_API_KEY".to_string());
            let engine = Engine::new(engine_config).await?;

            let model = engine.model("gpt-5".to_string()).await?.ok_or("Model not found")?;

            let messages = vec![
                ChatMessage::system().with_reasoning_effort(ReasoningEffort::Low),
                ChatMessage::user().with_text("How LLMs work".to_string()),
            ];

            let session = engine.chat(model, ChatConfig::default()).await?;
            let replies = session.reply(messages, ChatReplyConfig::default()).await?;
            if let Some(reply) = replies.first() {
                println!("Reasoning: {}", reply.message.reasoning().unwrap_or_default());
                println!("Text: {}", reply.message.text().unwrap_or_default());
            }

            Ok(())
        }
        ```
      </Step>

      <Step title="Run the snippet">
        ```sh theme={null}
        cargo run --release
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>
