> For the complete documentation index, see [llms.txt](https://docs.gitloom.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gitloom.cloud/documentation/rust.md).

# Rust

```toml
[dependencies]
gitloom = { version = "0.2", features = ["openai"] }
```

Provider-agnostic core; the `openai` feature adds conversions for [async-openai](https://crates.io/crates/async-openai).

## The proxy

`exchange` is one call where the SDK does everything but the provider request — memory context and the compaction summary are folded into the window it hands your closure, and both turns are stored afterwards:

```rust
let client = Client::new(""); // reads GITLOOM_API_KEY
let mut conv = Conversation::create(&client, "chat-42", ConversationOptions {
    model: "gpt-4o".into(),
    summarize_server: true, // GitLoom's model writes compaction summaries
    ..Default::default()
}).await?;

let reply = conv.exchange(vec![Message::user("What camera do I own?")], |window| async move {
    let res = my_openai_call(window).await?;   // your provider, your credentials
    Ok((Message::assistant(res.text), Some(gitloom::openai::usage_of(&res))))
}).await?;
```

## Multimodal and media

```rust
conv.append(vec![Message {
    role: "user".into(),
    content: Content::Parts(vec![
        Part::text_part("what's in this photo?"),
        Part::image_data(b64, "image/png"), // uploaded transparently, stored by reference
    ]),
    ..Default::default()
}], None).await?;
```

## Branching, edits, titles

```rust
conv.rewind(6).await?;
conv.edit(4, Message::user("ask differently")).await?;
conv.edit_in_place(4, "[redacted]").await?;
conv.set_title("Camera shopping").await?;
```

## Memory, directly

```rust
client.remember(&[Message::user("I moved to Pune.")], None).await?;
let res = client.recall("where do I live?", None).await?;
// every hit: scores.arms, provenance (history + diff), relations with snippets
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gitloom.cloud/documentation/rust.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
