Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI How-Tos

Free Upgrade Claude Code: local-access claude-sonnet-4-20250514 Models

2025-08-22 676

In the wave of AI-assisted development, developers are constantly looking for best practices to seamlessly integrate top-notch language models with local workflows. Anthropic introduced Claude Code As a powerful end-to-end native AI assistant, it can directly understand and manipulate the entire codebase, greatly improving development efficiency. Meanwhile, Amazon AWS' AI IDE Kiro In its free preview version, it provides access to Anthropic-specific models claude-sonnet-4-20250514 of access rights. The model achieves significant breakthroughs in coding capability, inference speed and cost-effectiveness.

In this paper, we present a clever combination of solutions: two lightweight tools developed through the community Ki2API cap (a poem) Claude Code Routerthat connects the two. The goal of this program is to allow developers to make almost no modifications to the Claude Code native experience, it's free to replace its back-end model with a more performant claude-sonnet-4-20250514The

Architecture Explained: How are workflows implemented?

The entire workflow forms a clear chain of local requests that will Claude Code The front-end interaction with the Kiro of the modeling backend is connected.

Request PathClaude Code -> Claude Code Router -> Ki2API -> Kiro (claude-sonnet-4-20250514)

  • Why do you need such an architecture?
    • Standardized OpenAI interfacesKi2API plays a key adapter role. It plays a key role in the local 8989 port to start a service that will Kiro The model calls are encapsulated in a format that is fully compatible with the OpenAI API, including the /v1/models cap (a poem) /v1/chat/completions path and supports streaming responses. This makes it easy to access any client that supports the OpenAI interface.
    • Flexible request routingClaude Code Router (CCR) It is a program designed for Claude Code designed proxy tool. It reads the local configuration file and can intercept the Claude Code The different types of requests issued (e.g., regular coding, background tasks, long context processing, etc.) and forward them to the specified backend model respectively.
    • High availability of models:: Adoption Kiro platform, developers can stabilize the use of claude-sonnet-4-20250514 Model. The model performs better and is more responsive when dealing with complex coding tasks and long process reasoning.

Three Steps to Local Configuration

Step 1: Start the Ki2API service

First, we need to start the Ki2APIIt will be used as a connection Kiro The local gateway to the platform.

git clone https://github.com/zhalice2011/ki2api
cd ki2api
docker-compose up -d

Service Default Listening http://localhost:8989The Ki2API automatically reads the local AWS SSO cache credentials (usually located in the ~/.aws/sso/cache/ directory), and has built-in automatic refresh logic. If desired, this can also be done via the KIRO_ACCESS_TOKEN cap (a poem) KIRO_REFRESH_TOKEN environment variable to manually specify credentials.

Step 2: Install Claude Code and Claude Code Router

Make sure you have the Node.jsand then through the npm global installation Claude Code cap (a poem) Claude Code RouterThe

# 如果已安装 Claude Code,可跳过此步
npm install -g @anthropic-ai/claude-code
# 安装路由工具
npm install -g @musistudio/claude-code-router

Step 3: Write the configuration file and start

establish Claude Code Router configuration file. Save the following JSON content in its entirety to the ~/.claude-code-router/config.json Path.

{
"LOG": false,
"OPENAI_API_KEY": "",
"OPENAI_BASE_URL": "",
"OPENAI_MODEL": "",
"Providers": [
{
"name": "openai",
"api_base_url": "http://localhost:8989/v1/chat/completions",
"api_key": "ki2api-key-2024",
"models": [
"claude-sonnet-4-20250514"
]
}
],
"Router": {
"default": "openai,claude-sonnet-4-20250514",
"background": "openai,claude-sonnet-4-20250514",
"think": "openai,claude-sonnet-4-20250514",
"longContext": "openai,claude-sonnet-4-20250514",
"webSearch": "openai,claude-sonnet-4-20250514"
}
}

Configuration:

  • Providers field defines the available backend services. Here we will name because of openai The service points to the local Ki2API The address of the
  • Router The field will Claude Code All task panels (defaultthink and so on) are routed to the openai services and claude-sonnet-4-20250514 Model.

Once the configuration is complete, execute the following command to start Claude Code::

ccr code

At this point.CCR receivership Claude Code of the web request and follow the Router The rule forwards it to the local Ki2API service, which ultimately calls the claude-sonnet-4-20250514 Model.

Frequently Asked Questions and Solutions

  • 401 Unauthorized error
    • Cause analysis: The API key is incorrect or Kiro of the access credentials have expired.
    • prescription:: Ensure that the configuration file api_key together with Ki2API preconfigured ki2api-key-2024 Consistent. Also, check Ki2API to confirm that it has successfully fetched or flushed the Docker container logs of the Kiro The access token for the
  • Port conflict or connection failure
    • Cause analysis: Local 8989 The port is already occupied by another program, or Ki2API The service failed to start properly.
    • prescription: Use docker-compose logs -f command to view Ki2API of the real-time logs to locate the problem. If there is a port conflict, you can modify the docker-compose.yml file, which will 8989 Mapping to other available ports and synchronizing updates CCR configuration file in the api_base_urlThe
  • Configuration changes do not take effect
    • Cause analysisClaude Code Router Load configuration at startup, runtime changes to files are not automatically reloaded.
    • prescription:: Modifications config.json file, you need to re-execute the ccr code command to restart the service for the new configuration to take effect.

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish