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

# Migrating from Bedrock

> Imports and client construction change; message shapes, tool configs, streaming loops, and error handling carry over verbatim.

Migration is intentionally boring. In every language, the change is confined to
**imports and client construction** — plus swapping Bedrock model ARNs for
AI Reserve model IDs (for example `gpt-5.4-mini`, `gpt-5.5`,
`claude-opus-4-8`). Message shapes, tool configs, streaming loops, and error
handling carry over verbatim.

| Bedrock concept                                 | AI Reserve equivalent                                  |
| ----------------------------------------------- | ------------------------------------------------------ |
| AWS region + credential chain / IAM             | One bearer key: `AUDACITY_API_KEY`                     |
| Model ARN (`anthropic.claude-3-5-sonnet-…`)     | AI Reserve model ID (`claude-opus-4-8`, `gpt-5.5`, …)  |
| `Converse` / `ConverseStream`                   | Identical — same names, same shapes                    |
| `toolConfig`, `toolUse`, `toolResult`           | Identical                                              |
| `ThrottlingException`, `ValidationException`, … | Identical exception names, same retryability semantics |
| Bedrock standard retry mode                     | Same policy: jittered backoff, `Retry-After` honored   |

<CodeGroup>
  ```diff Python theme={"dark"}
  -import boto3
  -client = boto3.client("bedrock-runtime", region_name="us-east-1")
  +from audacity import Audacity
  +client = Audacity(api_key="aireserve_api_…")   # only line that changes

   response = client.converse(
  -    modelId="anthropic.claude-3-sonnet-20240229-v1:0",
  +    modelId="gpt-5.4-mini",                   # use an AI Reserve model ID
       messages=[{"role": "user", "content": [{"text": "Hi"}]}],
   )

   # Streaming call sites are identical:
   stream_resp = client.converse_stream(modelId=…, messages=…)
   for event in stream_resp["stream"]:
       …
  ```

  ```diff TypeScript theme={"dark"}
  -import {
  -  BedrockRuntimeClient,
  -  ConverseCommand,
  -  ConverseStreamCommand,
  -} from "@aws-sdk/client-bedrock-runtime";
  +import {
  +  AudacityRuntimeClient as BedrockRuntimeClient,
  +  ConverseCommand,
  +  ConverseStreamCommand,
  +} from "@audacity/sdk";

  -const client = new BedrockRuntimeClient({ region: "us-east-1" });
  +const client = new BedrockRuntimeClient({ apiKey: process.env.AUDACITY_API_KEY });

   const response = await client.send(
     new ConverseCommand({
       modelId: "gpt-5.4-mini",
       messages: [{ role: "user", content: [{ text: "Hi" }] }],
     })
   );
  ```

  ```diff Go theme={"dark"}
   import (
  -    "github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
  -    "github.com/aws/aws-sdk-go-v2/service/bedrockruntime/types"
  +    "github.com/Audacity-Investments/audacity-sdk-go/audacityruntime"
  +    "github.com/Audacity-Investments/audacity-sdk-go/audacityruntime/types"
   )

  -client := bedrockruntime.NewFromConfig(cfg)
  +client := audacityruntime.New(audacityruntime.Options{})  // reads AUDACITY_API_KEY

   resp, err := client.Converse(ctx, &audacityruntime.ConverseInput{
  -    ModelId: aws.String("anthropic.claude-3-5-sonnet-20241022-v2:0"),
  +    ModelId: audacity.String("gpt-5.4-mini"),
       Messages: []types.Message{{ … }},
   })
  ```

  ```diff Java theme={"dark"}
  -BedrockRuntimeClient client = BedrockRuntimeClient.builder()
  -    .region(Region.US_EAST_1)
  -    .credentialsProvider(DefaultCredentialsProvider.create())
  -    .build();
  +var client = AudacityRuntimeClient.builder()
  +    .apiKey(System.getenv("AUDACITY_API_KEY"))
  +    .build();

   ConverseResponse response = client.converse(req -> req
  -    .modelId("anthropic.claude-3-5-sonnet-20241022-v2:0")
  +    .modelId("gpt-5.4-mini")
       .messages(Message.builder()
           .role(ConversationRole.USER)
           .content(ContentBlock.fromText("Hi"))
           .build())
       .inferenceConfig(cfg -> cfg.maxTokens(500).temperature(0.2f)));
  ```

  ```diff Rust theme={"dark"}
  -use aws_sdk_bedrockruntime::Client;
  -use aws_sdk_bedrockruntime::types::{ContentBlock, ConversationRole, Message};
  +use audacity_sdk::{Client, ContentBlock, ConversationRole, Message};

  -let config = aws_config::load_from_env().await;
  -let client = Client::new(&config);
  +let client = audacity_sdk::Client::from_env()?;   // reads AUDACITY_API_KEY

   let response = client.converse()
  -    .model_id("anthropic.claude-3-5-sonnet-20241022-v2:0")
  +    .model_id("gpt-5.4-mini")
       .messages(
           Message::builder()
               .role(ConversationRole::User)
               .content(ContentBlock::Text("Hello".into()))
               .build()?
       )
       .send()
       .await?;
  ```
</CodeGroup>

<Info>
  **Java note.** `converseStream` in the AI Reserve SDK is synchronous
  (a blocking push handler or a pull iterator) rather than the AWS async
  `CompletableFuture` publisher — for most codebases this removes boilerplate rather
  than adding it.
</Info>

## Bedrock-routed models

Some teams prefer a model's serving behavior *via AWS Bedrock* over the provider's
direct API. AI Reserve offers both paths behind the same endpoint: append
`-bedrock` to a model ID and the gateway routes that request through AWS
Bedrock instead of the provider directly. Everything else — SDK, key, shapes,
streaming, errors — is identical, so you can A/B the two paths by changing only the
model string.

```python theme={"dark"}
# Direct provider API
client.converse(modelId="claude-opus-4-8", messages=…)

# Same model, routed through AWS Bedrock
client.converse(modelId="claude-opus-4-8-bedrock", messages=…)
```

| Direct model ID             | Bedrock-routed variant      |
| --------------------------- | --------------------------- |
| `claude-fable-5`            | `claude-fable-5-bedrock`    |
| `claude-opus-4-8`           | `claude-opus-4-8-bedrock`   |
| `claude-opus-4-7`           | `claude-opus-4-7-bedrock`   |
| `claude-opus-4-6`           | `claude-opus-4-6-bedrock`   |
| `claude-sonnet-4-6`         | `claude-sonnet-4-6-bedrock` |
| `claude-sonnet-4-5`         | `claude-sonnet-4-5-bedrock` |
| `claude-haiku-4-5-20251001` | `claude-haiku-4-5-bedrock`  |
| `llama-4-maverick`          | `llama-4-maverick-bedrock`  |
| `llama-4-scout`             | `llama-4-scout-bedrock`     |
| `mistral-large`             | `mistral-large-bedrock`     |
| `deepseek-reasoner`         | `deepseek-reasoner-bedrock` |

Models that Bedrock does not serve (OpenAI GPT, Gemini, Grok, Perplexity Sonar, Moonshot)
have no `-bedrock` variant — the direct IDs remain the only path for those.

All variants route through AWS Bedrock except `claude-fable-5-bedrock`,
`claude-opus-4-8-bedrock`, and `claude-opus-4-7-bedrock`, which
temporarily serve via Anthropic's direct API while Bedrock access for those models is
being enabled on our AWS account — the IDs are stable and will be re-pointed
gateway-side with no client change.

## Latency

Compared to calling a provider (or Bedrock) directly from your own code, the AI Reserve
gateway adds a small, **fixed** toll — authentication, rate limiting,
quota checks, and request translation:

| Component                          | Added latency |
| ---------------------------------- | ------------- |
| Auth + rate limit (gateway edge)   | \~10–30 ms    |
| Quota / spend-cap checks (proxy)   | \~10–30 ms    |
| Request translation (router)       | \~20–60 ms    |
| Cross-cloud hop (region dependent) | \~5–40 ms     |

Rule of thumb: **\~60–200 ms added to time-to-first-token, and effectively
zero between tokens** — streaming responses are piped through without
re-buffering, so inter-token latency is determined entirely by the model provider.
Against typical generation times of seconds to tens of seconds, the overhead is low
single-digit percent. The toll does not grow with context size or generation length.

Note that provider-side differences (for example, Bedrock vs. direct-API
time-to-first-token for the same Claude model, which varies by region and load) are
independent of the gateway and typically larger than the gateway's own overhead. The
`-bedrock` variants make measuring both paths for your workload a
one-string A/B test.

Already on boto3 or the AWS JS SDK and want to keep them? See
[AWS SDK (boto3)](/connect/aws-sdk) — the gateway serves the Bedrock Converse API at the
same paths, so unmodified clients work by overriding the endpoint.
