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

# Migrate to AI SDK 7

> Move a The Context Company AI SDK 5 or 6 integration to AI SDK 7 stable telemetry.

AI SDK 7 replaces experimental OpenTelemetry options with stable telemetry integrations and runtime context. The Context Company supports both formats, so you can deploy server-side ingestion support before migrating application code.

## Compatibility

| Application | TCC package              | Node.js     | Call configuration                      |
| ----------- | ------------------------ | ----------- | --------------------------------------- |
| AI SDK 5    | `@contextcompany/otel`   | 18 or newer | `experimental_telemetry`                |
| AI SDK 6    | `@contextcompany/otel`   | 18 or newer | `experimental_telemetry`                |
| AI SDK 7    | `@contextcompany/ai-sdk` | 22 or newer | `runtimeContext` and stable `telemetry` |

## Migration steps

1. Upgrade Node.js to version 22 or newer.
2. Upgrade `ai`, provider packages, and React bindings to their AI SDK 7-compatible major versions.
3. Replace `@contextcompany/otel` with `@contextcompany/ai-sdk` in the application.
4. Replace `registerOTelTCC` with `registerTCC`.
5. Move `experimental_telemetry.metadata` into `tccTelemetry`, preserving every reserved `tcc.*` key.
6. Run a multi-step tool call and confirm its run, model steps, tool calls, usage, and metadata in The Context Company.

## Registration

<CodeGroup>
  ```typescript Before theme={null}
  const { registerOTelTCC } = await import("@contextcompany/otel/nextjs");
  registerOTelTCC();
  ```

  ```typescript After theme={null}
  const { registerTCC } = await import("@contextcompany/ai-sdk/nextjs");
  registerTCC();
  ```
</CodeGroup>

## Per-call metadata

<CodeGroup>
  ```typescript Before theme={null}
  streamText({
    model,
    prompt,
    experimental_telemetry: {
      isEnabled: true,
      metadata: {
        "tcc.runId": runId,
        "tcc.sessionId": sessionId,
        environment: "production",
      },
    },
  });
  ```

  ```typescript After theme={null}
  import { tccTelemetry } from "@contextcompany/ai-sdk/nextjs";

  streamText({
    model,
    prompt,
    ...tccTelemetry({
      metadata: {
        "tcc.runId": runId,
        "tcc.sessionId": sessionId,
        environment: "production",
      },
    }),
  });
  ```
</CodeGroup>

## Common AI SDK 7 API changes

* Use `instructions` instead of `system` when following the current text-generation API.
* Use `isStepCount` instead of `stepCountIs`.
* Use stable `telemetry` instead of `experimental_telemetry`.
* Put application tracking data in the `tccTelemetry` metadata object.
* Keep the `tcc.*` prefix on every TCC-specific metadata key.

`tccTelemetry` handles runtime-context inclusion automatically. Application-specific metadata such as `environment` remains unprefixed. The `tcc.*` namespace is reserved for supported TCC metadata keys.

## Rollback

The ingest service accepts legacy and AI SDK 7 spans simultaneously. If the application migration needs to be rolled back, restore the AI SDK 5 or 6 application dependencies and continue using `@contextcompany/otel`. No stored-data migration is required.
