Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"name": "gemini-to-nova-migration",
"source": "./skills/gemini-to-nova-migration",
"description": "Migrate Google Gemini 2.0/2.5/3.x Python code and prompts to Amazon Nova 2 Lite (boto3 Bedrock Runtime)."
},
{
"name": "openai-to-nova-migration",
"source": "./skills/openai-to-nova-migration",
"description": "Migrate OpenAI GPT-4o/4.1/5.x Python code and prompts to Amazon Nova 2 Lite (boto3 Bedrock Runtime)."
}
]
}
3 changes: 2 additions & 1 deletion skills/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Reusable [Agent Skills](https://agentskills.io/specification) for building with
| [text-agent-to-strands-voice-agent](./text-agent-to-strands-voice-agent/) | Migrate a text-based agent to a real-time voice agent using Strands BidiAgent with Amazon Nova Sonic |
| [nova-prompter](./nova-prompter/) | Write and optimize prompts for Amazon Nova 1 and Nova 2 Lite — Claude Code plugins (`/nova1-prompt`, `/nova2-prompt`) and matching Kiro powers, with multimodal coverage for Nova 2 |
| [titan-nova-mme-migration](./titan-nova-mme-migration/) | Migrate Amazon Bedrock embedding code from Titan Text V2 / Titan Multimodal G1 to Amazon Nova Multimodal Embeddings — handles request schema, dimension mapping, `embeddingPurpose`, and client-side text+image fusion |
| [gemini-to-nova-migration](./gemini-to-nova-migration/) | Migrate Google Gemini 2.0/2.5/3.x Python code and prompts to Amazon Nova 2 Lite — converts SDK calls (`google-genai` / `google-generativeai` → `boto3` Bedrock `converse`), rewrites prompts to `##Section##` format, handles multimodal, tool calling, structured output, streaming, and reasoning mode |
| [gemini-to-nova-migration](./gemini-to-nova-migration/) | Migrate Google Gemini 2.0/2.5/3.x Python code and prompts to Amazon Nova 2 Lite — converts SDK calls (`google-genai` / `google-generativeai` → `boto3` Bedrock `converse`), rewrites prompts to `##Section##` format, handles multimodal, tool calling, structured output, streaming, and reasoning mode |
| [openai-to-nova-migration](./openai-to-nova-migration/) | Migrate OpenAI GPT-4o/4.1/5.x Python code and prompts to Amazon Nova 2 Lite — converts SDK calls (`openai` → `boto3` Bedrock `converse`) across Chat Completions, Responses, and Assistants APIs, extracts system prompts, nests inference params, rewrites prompts to `##Section##` format, and handles multimodal, tool calling, structured output, streaming, and extended thinking |
22 changes: 22 additions & 0 deletions skills/openai-to-nova-migration/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"author": {
"name": "Amazon Web Services"
},
"description": "Migrate OpenAI (GPT-4o, GPT-4.1, GPT-5.x) Python code and prompts to Amazon Nova 2 Lite (boto3 Bedrock Runtime). Handles SDK conversion, request/response restructuring, prompt reformatting, tool calling, structured output, multimodal, and extended thinking migration.",
"homepage": "https://github.com/aws-samples/amazon-nova-samples",
"keywords": [
"bedrock",
"nova",
"openai",
"gpt",
"migration",
"python",
"boto3",
"prompt-engineering",
"aws"
],
"license": "Apache-2.0",
"name": "openai-to-nova-migration",
"repository": "https://github.com/aws-samples/amazon-nova-samples",
"version": "1.0.0"
}
127 changes: 127 additions & 0 deletions skills/openai-to-nova-migration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# OpenAI → Nova 2 Lite Migration Skill

An [Agent Skill](https://agentskills.io/specification) that migrates OpenAI Python code and prompts to [Amazon Nova 2 Lite](https://docs.aws.amazon.com/nova/latest/nova2-userguide/getting-started-nova-2.html) (`us.amazon.nova-2-lite-v1:0`) on Amazon Bedrock.

The skill converts SDK calls (`openai` → `boto3` Bedrock Runtime `converse`) and rewrites prompts to follow Nova 2 Lite formatting and constraints. This is not a one-line model swap — authentication, message structure, parameter nesting, and error handling all change. Every migration delivers two things: **working migrated code** and an **explanation of every change**, including any features that can't be ported 1:1.

The skill supports **GPT-4o, GPT-4.1, GPT-5.x**, and legacy GPT-4 / GPT-3.5 as source models, across three API styles:

| Source API style | Detected from |
|---|---|
| Chat Completions API | `client.chat.completions.create(...)` |
| Responses API | `client.responses.create(...)` — `instructions=` + `input=` |
| Assistants API | `client.beta.assistants.create(...)` / `client.beta.threads.*` |

**Target:** `us.amazon.nova-2-lite-v1:0`

## Skill structure

```
openai-to-nova-migration/
├── SKILL.md # Skill instructions and migration workflow
├── README.md # This file
└── references/
├── feature-mapping.md # Complete OpenAI → Nova mapping tables
├── code-examples.md # Before/after code patterns
└── chat-completions-patterns.md # Chat Completions, Responses API + Assistants API specifics
```

## What the skill handles

| Area | Detail |
|---|---|
| SDK | `openai` → `boto3` bedrock-runtime `converse` / `converse_stream` |
| Auth | `OPENAI_API_KEY` (bearer token) → AWS IAM credentials |
| Request structure | `role: "system"` message → `system=[{"text": ...}]`; flat string content → typed content blocks |
| Inference params | Top-level `max_tokens`/`temperature`/`top_p` → nested `inferenceConfig` with camelCase |
| Prompt format | Free-form → `##Section Name##` delimiters with canonical Nova section names |
| Multimodal | Enforces system-prompt-is-persona-only rule, media-before-text ordering, URL/base64 → raw bytes |
| Function calling | `tools` (function) → `toolSpec`, `tool_choice` → `toolChoice` |
| Structured output | `response_format` → inline schema (simple) or tool-forcing (complex) |
| Reasoning | `reasoning_effort` (GPT-5.x) → `additionalModelRequestFields.reasoningConfig`, mapped to a Nova effort level |
| Built-in tools | Assistants code interpreter / file search → Nova `nova_code_interpreter` / Bedrock Knowledge Bases |
| Error handling | `RateLimitError` / `APIError` → `ThrottlingException` / `ValidationException` |

## API differences at a glance

| | OpenAI | Nova 2 Lite |
|---|---|---|
| **SDK** | `openai` | `boto3` bedrock-runtime |
| **Call** | `client.chat.completions.create()` / `client.responses.create()` | `client.converse()` |
| **Auth** | `OPENAI_API_KEY` | AWS credentials (IAM role, profile, env vars) |
| **System prompt** | `{"role": "system", ...}` message | `system=[{"text": ...}]` (persona only for multimodal) |
| **Message content** | Flat string | Typed content blocks (`[{"text": ...}]`) |
| **Inference params** | Top-level `max_tokens`, `temperature`, `top_p` | Nested `inferenceConfig` (`maxTokens`, `temperature`, `topP`) |
| **Tools** | `tools=[{"type": "function", ...}]` | `toolConfig={"tools": [{"toolSpec": ...}]}` |
| **Tool choice** | `tool_choice` (`auto`/`required`/`none`) | `toolChoice` (`auto`/`any`/`tool`) |
| **Structured output** | `response_format` (JSON schema) | Inline prompt schema or tool-forcing |
| **Reasoning** | `reasoning_effort` (GPT-5.x) | `additionalModelRequestFields={"reasoningConfig": {...}}` |
| **Streaming** | `stream=True` | `converse_stream()` |
| **Stateful turns** | Assistants threads, `previous_response_id` | Pass full message history each call |
| **Images** | URL or base64 data URI | Raw binary bytes; media MUST precede text |
| **Errors** | `RateLimitError` / `APIError` | `ThrottlingException` / `ValidationException` |

## Reasoning effort mapping

When the source model supports reasoning effort (GPT-5.x, `o1`, `o3`) **and** it's enabled, the skill asks the user which Nova effort level to use:

| Nova effort | Config |
|---|---|
| `low` | `additionalModelRequestFields={"reasoningConfig": {"type": "enabled", "maxReasoningEffort": "low"}}` |
| `medium` | `additionalModelRequestFields={"reasoningConfig": {"type": "enabled", "maxReasoningEffort": "medium"}}` |
| `high` | `additionalModelRequestFields={"reasoningConfig": {"type": "enabled", "maxReasoningEffort": "high"}}` — must omit `inferenceConfig` and set client `read_timeout=3600` |

OpenAI and Nova effort scales are not numerically equivalent — start at Nova `low` and increase only if evaluation shows quality gaps. If the source model has no native reasoning (e.g. `gpt-4o`), or `reasoning_effort` isn't enabled, omit `additionalModelRequestFields` entirely (reasoning is disabled by default).

## Installation

### Claude Code

This skill ships as the `openai-to-nova-migration` plugin via the `aws-samples-amazon-nova-samples` marketplace.

Add the marketplace, then install the plugin:

```
/plugin marketplace add https://github.com/aws-samples/amazon-nova-samples
/plugin install openai-to-nova-migration@aws-samples-amazon-nova-samples
```

After install, invoke the skill on your OpenAI code with `/openai-to-nova`.

## Prerequisites

- An AWS account with Amazon Bedrock access
- `us.amazon.nova-2-lite-v1:0` enabled in your region
- Python 3.8+ with `boto3` (only needed to run the migrated code)
- `bedrock:InvokeTool` IAM permission if migrating to Nova's built-in web grounding or code interpreter

AWS credentials and Bedrock access are only required when you actually run the migrated code — the migration itself runs inside the host tool.

## Example prompts

```
Migrate this OpenAI code to Amazon Nova 2 Lite:
<paste your openai SDK code>
```

```
I have a GPT-5.2 function-calling app with reasoning_effort="high".
Convert it to Nova 2 Lite.
```

```
Rewrite this GPT-4o multimodal prompt (image input) for Nova 2 Lite.
```

```
Migrate this OpenAI Assistants API app (code interpreter) to Nova 2 Lite.
```

## Related resources

- [Amazon Nova 2 User Guide](https://docs.aws.amazon.com/nova/latest/nova2-userguide/getting-started-nova-2.html)
- [Amazon Nova 2 Prompt Engineering Guide](https://docs.aws.amazon.com/nova/latest/nova2-userguide/prompt-engineering-guide.html)
- [Migrate from Amazon Nova 1 to Amazon Nova 2 on Amazon Bedrock](https://aws.amazon.com/blogs/machine-learning/migrate-from-amazon-nova-1-to-amazon-nova-2-on-amazon-bedrock/)
- [Amazon Bedrock `converse` API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html)
- [Agent Skills open standard — Anthropic](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills)
- [Amazon Nova Samples](https://github.com/aws-samples/amazon-nova-samples)
Loading