Tutorials

How to Use Amazon Ergo 1.0 with Node.js and TypeScript

Amazon Ergo 1.0 is now available through AWS Bedrock. Learn how to integrate it into a TypeScript application using the OpenAI SDK, configure cross-region inference, and avoid common API errors.

An application already using the OpenAI SDK does not necessarily need another SDK to communicate with a different AI provider.

Amazon Bedrock supports an OpenAI-compatible API, allowing developers to reuse much of their existing integration. With the release of Amazon Ergo 1.0 on December 1, 2026, this becomes particularly useful for applications focused on software development and agentic workflows.

There are, however, a few differences hiding behind the familiar API.

The endpoint belongs to AWS, authentication uses Bedrock credentials, and the model identifier cannot be used directly without an inference profile.

Even a correctly authenticated request can fail if one of these details is overlooked.

What is Amazon Ergo 1.0?

Ergo is Amazon’s open-weight mixture-of-experts model designed primarily for programming, technical reasoning, and long-running agentic tasks.

Its specifications at launch are:

Specification Amazon Ergo 1.0
Total parameters 1.1 trillion
Active parameters per token 55 billion
Context window 1 million tokens
Maximum output 131,072 tokens
Global input price $1 per million tokens
Global output price $3 per million tokens
Supported modalities Text input and output

Amazon reports generation speeds exceeding 400 output tokens per second on Bedrock. This is a manufacturer-reported figure, not an independently measured result for the examples in this article.

Although the model weights are distributed under Amazon’s own open-weights license, using the hosted Bedrock API does not require downloading them.

All inference runs on AWS infrastructure.

1. Prepare a TypeScript project

For a small standalone example, create a Node.js project:

mkdir ergo-demo
cd ergo-demo
npm init -y
pnpm add openai
pnpm add -D typescript tsx @types/node

The openai package provides the API client. TypeScript and tsx allow us to write and execute the example without preparing a separate compilation pipeline.

Create the following project structure:

ergo-demo/
├── src/
│   ├── client.ts
│   └── index.ts
├── .env
├── .gitignore
└── package.json

The examples use Node.js 22 or later.

2. Generate an Amazon Bedrock API key

An ordinary OpenAI API key will not authenticate requests sent to Amazon Bedrock.

Despite using the OpenAI SDK, the application communicates with AWS.

Open the Amazon Bedrock console and navigate to the API keys section.

For an initial experiment, you can generate a Bedrock API key and store it in .env:

AWS_BEARER_TOKEN_BEDROCK=your-bedrock-api-key
AWS_REGION=eu-central-1

Add .env to .gitignore:

node_modules/
.env

AWS recommends short-term credentials for production environments. A long-term API key may be convenient for initial exploration, but it should not become an indefinitely stored production credential.

Also keep the integration on the server. An API key included in a React frontend or another browser application can be extracted and used by someone else.

3. Configure the OpenAI client

Create src/client.ts:

import OpenAI from "openai";

const apiKey = process.env.AWS_BEARER_TOKEN_BEDROCK;
const region = process.env.AWS_REGION ?? "us-west-2";

if (!apiKey) {
  throw new Error("Missing AWS_BEARER_TOKEN_BEDROCK");
}

export const client = new OpenAI({
  apiKey,
  baseURL:
    `https://bedrock-runtime.${region}.amazonaws.com/openai/v1`,
});

export const model = "global.amazon.ergo-1.0";

The SDK remains unchanged. What changes is the destination of its HTTP requests.

Instead of sending them to OpenAI’s infrastructure, the client uses the regional Amazon Bedrock Runtime endpoint.

The /openai/v1 suffix is part of that endpoint’s OpenAI-compatible interface.

There is also a less obvious detail in the model identifier:

"global.amazon.ergo-1.0"

The global. prefix is necessary here because Ergo does not support direct in-region inference.

4. Send your first request

Create src/index.ts:

import { client, model } from "./client";

async function main() {
  const response = await client.responses.create({
    model,
    input: "Explain dependency injection in TypeScript with a short example.",
    max_output_tokens: 8192,
  });

  console.log(response.output_text);
}

main().catch(console.error);

Execute the file:

node --env-file=.env --import tsx src/index.ts

The request uses the familiar Responses API. If the credentials, region, permissions, and model identifier are correct, the application should receive generated text.

There is no need to manually construct authorization headers or parse the raw HTTP response.

But why use an output limit of 8,192 tokens for a relatively simple programming question?

Ergo performs reasoning before producing its final answer. Some of the output budget is consumed by that process.

AWS recommends allowing at least 8,192 output tokens to avoid situations where the model exhausts its budget before generating a useful answer.

This is a limit, not a requirement for the model to generate exactly that many tokens.

5. Why amazon.ergo-1.0 can return HTTP 400

AWS documents the underlying model ID as:

amazon.ergo-1.0

Naturally, a developer might try to use it directly:

const response = await client.responses.create({
  model: "amazon.ergo-1.0",
  input: "Hello",
});

However, Ergo does not support this invocation mode.

The model is accessible through cross-region inference profiles:

Inference profile Routing
global.amazon.ergo-1.0 Global cross-region inference
us.amazon.ergo-1.0 US geographic cross-region inference
amazon.ergo-1.0 Direct in-region inference is unsupported

The difference is between identifying the underlying model and specifying how Bedrock should route the request.

Consider the configuration used earlier:

AWS_REGION=eu-central-1

The application sends its request to Frankfurt. But the selected global inference profile allows AWS to process that request in another supported region.

flowchart TD
    A["Node.js application"] --> B["Bedrock endpoint: eu-central-1"]
    B --> C["Global inference profile"]
    C --> D["AWS selects an eligible inference region"]
    D --> E["Amazon Ergo 1.0"]
    E --> F["Response returned to application"]

The endpoint region and inference region are not necessarily the same.

This distinction becomes significant when an application has geographic data-processing restrictions.

Selecting a European endpoint does not guarantee that inference remains within Europe when using the global profile. At launch, Ergo does not provide a dedicated European geographic inference profile.

6. Stream generated responses

Waiting for the complete response is reasonable for background jobs. For an interactive application, it may be preferable to display text as it arrives.

Create src/stream.ts:

import { client, model } from "./client";

async function main() {
  const stream = await client.responses.create({
    model,
    input: "Explain the difference between Map and WeakMap in JavaScript.",
    max_output_tokens: 8192,
    stream: true,
  });

  for await (const event of stream) {
    if (event.type === "response.output_text.delta") {
      process.stdout.write(event.delta);
    }
  }

  process.stdout.write("\n");
}

main().catch(console.error);

Run it with:

node --env-file=.env --import tsx src/stream.ts

The stream contains structured events rather than plain text fragments alone.

Checking event.type allows the application to distinguish generated text from other response information.

For a production integration, also handle incomplete responses, stream failures, and completion events. Receiving some generated text does not necessarily mean the entire request completed successfully.

7. Handle common API errors

An unsuccessful request does not always indicate a problem with the prompt.

The application may be using the wrong inference profile, an expired credential, or an account with insufficient permissions.

A small error handler can make these problems easier to distinguish:

import OpenAI from "openai";
import { client, model } from "./client";

async function askErgo(input: string) {
  try {
    const response = await client.responses.create({
      model,
      input,
      max_output_tokens: 8192,
    });

    if (response.status === "incomplete") {
      console.warn("The response did not complete.");
      console.warn(response.incomplete_details);
    }

    return response.output_text;
  } catch (error) {
    if (error instanceof OpenAI.APIError) {
      switch (error.status) {
        case 400:
          console.error("Check the model ID and request parameters.");
          break;

        case 401:
        case 403:
          console.error("Check AWS credentials and IAM permissions.");
          break;

        case 429:
          console.error("Bedrock rate or token quota exceeded.");
          break;

        default:
          console.error("Bedrock API error:", error.status);
      }
    }

    throw error;
  }
}

askErgo("Explain TypeScript generics.")
  .then(console.log)
  .catch(() => {
    process.exitCode = 1;
  });

The HTTP status provides a starting point for investigation. The actual error message may identify a more specific cause.

For instance, a 400 response can occur because the base model ID was used instead of an inference profile. It can also occur when requesting an unsupported configuration.

Ergo always performs reasoning. Explicitly selecting a reasoning effort of none is unsupported.

A 403 response, meanwhile, may indicate missing IAM permissions or invalid Bedrock credentials.

Changing the prompt will not resolve either problem.

How much does using Amazon Ergo cost?

For Global Standard inference, the announced prices are:

  • $1 per million input tokens.
  • $3 per million output tokens.

Suppose an application sends 10,000 input tokens and generates 2,000 billable output tokens.

The estimated cost is:

Usage Cost
10,000 input tokens $0.010
2,000 output tokens $0.006
Total $0.016

At those same token counts, 1,000 requests would cost approximately $16.

This calculation excludes caching and other applicable service charges. It also assumes that the output count includes all billable output, including reasoning tokens where applicable.

The US geographic inference profile has different pricing: $1.10 per million input tokens and $3.30 per million output tokens.

A large context window does not mean every request consumes one million tokens. Nevertheless, repeatedly sending entire source trees or conversation histories can make an otherwise inexpensive integration considerably more expensive.

Where available, inspect the usage information returned by the API:

console.log(response.usage);

It provides a better basis for monitoring actual consumption than estimating costs from the visible answer alone.

Can Ergo replace an existing OpenAI integration?

For basic text generation, the migration may involve little more than changing the API endpoint, credentials, and model identifier.

More complex applications deserve additional attention.

An application using function calling, structured outputs, reasoning settings, or provider-specific tools may rely on behavior that is not identical across models.

API compatibility describes how requests and responses are represented. It does not guarantee that every capability behaves the same way.

For example, an agent can receive a tool call through the API, but the application remains responsible for validating its arguments, authorizing the requested operation, and executing the corresponding function.

The model does not inherit permission to run arbitrary application code simply because it supports tool calling.

For an existing TypeScript application, the most practical starting point is a small, isolated API client. Once ordinary requests and streaming work correctly, additional capabilities can be introduced and tested individually.

Amazon Ergo’s release makes that initial integration relatively simple. The details that require more consideration are the ones outside the familiar SDK interface: AWS authentication, cross-region routing, reasoning budgets, and token consumption.

External Sources used for this article

Related Articles

View all →