Kimi Code CLI Amazon Bedrock Setup: Use Your AWS Profile, Scope IAM to One Inference Profile and Verify the First Run

Kimi Code CLI Amazon Bedrock setup: configure the native bedrock provider with your AWS profile, scope IAM to one inference profile and verify the first run.

Hero for the Kimi Code CLI Amazon Bedrock setup: three AWS credential chain chips feed a short-term bearer token disc inside a dashed expiry ring, which leads to bedrock-runtime.us-east-1, the global.moonshotai.kimi-k3.1 profile and global routing; a red dashed chip reads Stored API key: removed.Hero for the Kimi Code CLI Amazon Bedrock setup: three AWS credential chain chips feed a short-term bearer token disc inside a dashed expiry ring, which leads to bedrock-runtime.us-east-1, the global.moonshotai.kimi-k3.1 profile and global routing; a red dashed chip reads Stored API key: removed.
Your AWS profile mints the key: the native bedrock provider turns ambient credentials into short-term Bedrock tokens that last at most 12 hours or the session, so config.toml holds a Region and a profile name, never a key. Pattern from the AWS Machine Learning Blog (Nov 19, 2026) and the Kimi Code providers docs; profile dev-bedrock is illustrative.

You already sign in to AWS every morning, through IAM Identity Center or a named profile, and you want Kimi Code CLI to send its coding work to Kimi K3.1 on Amazon Bedrock under that same identity. Until now the path ran through a generic OpenAI-compatible provider and a separate Bedrock API key: one more secret to mint, paste into a config file and remember to revoke. This Kimi Code CLI Amazon Bedrock setup removes that secret. You will point the native bedrock provider at your AWS profile, attach an IAM policy that allows exactly one global inference profile, and prove the whole path with a headless prompt before the agent touches a real repository.

This guide is for a developer or platform engineer who already has a working AWS CLI profile, can get a policy attached to the role behind it, and wants a coding agent that leaves no long-lived Bedrock credential on disk. You finish with four artifacts you can copy: a complete ~/.kimi-code/config.toml, a five-statement IAM policy, a login-and-run command sequence, and a filled test table for one case, run:kimi-bedrock-01, that walks a success path and several deliberate failures.

The news itself is short. Moonshot AI’s Kimi Code CLI 2.7.0 release on November 19, 2026 adds Amazon Bedrock providers, configured with type = "bedrock" and AWS_REGION. The same day, the AWS Machine Learning Blog published a walkthrough of that provider, using Kimi K3.1 Pro Highspeed through the global inference profile global.moonshotai.kimi-k3.1. If you also run Claude Code on Bedrock, the Claude Code Bedrock and Vertex AI setup guide covers that CLI’s different variables and credential model; for where Kimi Code sits among other Chinese coding agents, see our survey of Qwen Code, Kimi Code CLI and coding plans. Everything below is grounded in the AWS post, the Kimi Code providers reference and four Amazon Bedrock User Guide pages. Where those documents stop, this guide says so.

AWS Machine Learning Blog page for the post titled Use Kimi Code CLI with models on Amazon Bedrock, with author byline dated 19 NOV 2026 and opening paragraphs.
AWS Machine Learning Blog, "Use Kimi Code CLI with models on Amazon Bedrock" (byline dated November 19, 2026), captured as served by Amazon Web Services. The opening paragraphs introduce the native bedrock provider in Kimi Code CLI v2.7.0. · Original source

How the native provider gets a key you never stored

The bedrock provider still authenticates to Bedrock with a bearer token, the same kind of credential an Amazon Bedrock API key is. What changes is who creates the token and how long it lives. The AWS post describes four steps:

  1. Resolve credentials. Unless you configure a Bedrock API key, the provider uses the standard AWS credential chain. AWS_PROFILE selects a named profile, including one backed by single sign-on.
  2. Mint a short-term token. The provider uses @aws/bedrock-token-generator to create a short-term Amazon Bedrock API key and renews it when needed.
  3. Build the endpoint. It reads AWS_REGION or AWS_DEFAULT_REGION and constructs the regional bedrock-runtime endpoint for the model’s API. For Kimi models that is the OpenAI-compatible Chat Completions path.
  4. Call the profile. The alias maps to a Bedrock model or inference profile ID. The global. prefix picks the global profile, while AWS_REGION picks the regional endpoint that receives the request.

The token’s limits come from Amazon Bedrock, not from Kimi. The Bedrock API keys page says a short-term key lasts up to 12 hours or the length of the session that produced it, whichever is shorter, and inherits the permissions of the IAM principal that generated it. AWS recommends short-term keys for production and describes long-term keys, which create an IAM user, as suitable only for exploration. The token Kimi holds can therefore never do more than your role and never outlive your sign-in.

Two consequences shape the rest of the setup. First, because the request still carries a bearer token, your identity needs bedrock:CallWithBearerToken as well as the invoke actions. The Bedrock API key permissions page defines that action and its bedrock:bearerTokenType condition key, which takes SHORT_TERM or LONG_TERM. Second, an explicit key always wins. The Kimi Code providers reference says a key set through api_key, api_key_env or the AWS_BEARER_TOKEN_BEDROCK key in [providers.bedrock.env] takes precedence over the ambient credential chain. One forgotten line quietly turns a keyless setup back into a keyed one, which is why the verification in Step 4 starts by searching for those names.

Sequence diagram for run:kimi-bedrock-01 with lanes Kimi Code CLI, AWS credential chain and Bedrock us-east-1: resolve profile dev-bedrock, temporary credentials, mint short-term bearer token, request to global.moonshotai.kimi-k3.1, authorize 3 ARNs then route, streamed answer.Sequence diagram for run:kimi-bedrock-01 with lanes Kimi Code CLI, AWS credential chain and Bedrock us-east-1: resolve profile dev-bedrock, temporary credentials, mint short-term bearer token, request to global.moonshotai.kimi-k3.1, authorize 3 ARNs then route, streamed answer.
Illustrative sequence for run:kimi-bedrock-01: the token is minted on the laptop from the dev-bedrock session, then Bedrock authorizes the profile and two model ARNs before routing. Only the Region and profile name live in config.toml. Steps from the AWS Machine Learning Blog (Nov 19, 2026) and the Bedrock global cross-Region inference docs.

The providers reference also explains how one provider serves several model families. Kimi strips any cross-Region prefix such as global. or us. from the model ID and picks the wire protocol from what remains: anthropic.* uses the Anthropic Messages API, openai.gpt-oss* uses Chat Completions, other openai.* models use the Responses API, and moonshotai.* or moonshot.* use Chat Completions, as the Kimi model cards recommend. Any other prefix defaults to Chat Completions. Adding a Claude alias later is a new [models.*] table under the same provider, not a second provider. If you are wiring your own application to Bedrock rather than using a CLI, the Spring AI Bedrock agent guide covers that route.

Before you start: what this setup needs

Work through this list before you edit any file. Each line is a place where the first run can fail for a reason that has nothing to do with Kimi.

  • [ ] Kimi Code CLI 2.7.0 or later. Run kimi --version. The native provider does not exist in earlier versions.
  • [ ] AWS CLI v2 with a working profile. The SSO commands below are AWS CLI v2 commands. The optional aws login console-credential flow needs v2.32.0 or later.
  • [ ] Model access in your source Region. The inference profile prerequisites page requires access to the model defined in the profile, in the Region you call from. Check the Kimi K3.1 Pro Highspeed model card for current Region and inference-profile support.
  • [ ] Someone who can attach IAM policy to the role behind your profile. The AWS post suggests a dedicated IAM role for Kimi Code CLI, separate from your regular AWS activity.
  • [ ] A data-residency decision. Global cross-Region inference can process requests in any supported commercial AWS Region. If your organization requires geographic containment, settle which profile you may use before continuing. If no hosted profile fits, self-hosting is the other route; Moonshot has published Kimi K3.1 Pro open weights.
  • [ ] A cost check. The global cross-Region inference page says global profiles cost about 10% less than geographic ones on both input and output tokens, priced by the Region you call from. Review Amazon Bedrock pricing before you hand an agent a large repository.

The worked case uses fixed, illustrative values so that every command and expected result lines up:

Field Value in run:kimi-bedrock-01 Note
AWS account 111122223333 The placeholder account AWS documentation uses; substitute your own
AWS profile dev-bedrock SSO-backed profile for a dedicated Kimi role
Source Region us-east-1 Illustrative; confirm on the model card that it is a supported source Region
Kimi alias bedrock-kimi-k3-1 Local name Kimi Code CLI uses to select the model
Bedrock model value global.moonshotai.kimi-k3.1 Global inference profile ID from the AWS post

A dedicated role pays off beyond this guide. When several agents share one laptop, separate identities are what let you tell their calls apart afterwards; the argument is made at length in AI agent identity as a service principal and, for running many CLIs side by side, in Ten assistants, one boss.

Step 1: Sign in with the AWS profile Kimi will use

The short-term token inherits whatever the signed-in principal can do, so the identity you confirm in this step is the ceiling on everything Kimi does later.

  1. Create the profile once. With IAM Identity Center:

    aws configure sso --profile dev-bedrock
    

    Choose account 111122223333 and the role or permission set your administrator created for Kimi Code.

  2. Sign in for today’s session:

    aws sso login --profile dev-bedrock
    

    If your organization uses console credentials instead, AWS CLI v2.32.0 or later supports aws login --profile dev-bedrock. The AWS post points to a console-credential login guide that also documents a credential_process configuration for tools that cannot read the cached login session directly. Omit --profile everywhere only if you deliberately use the default profile.

  3. Confirm which identity resolved:

    aws sts get-caller-identity --profile dev-bedrock
    

    Expected observation: the output names account 111122223333 and the role you intended for Kimi. If it shows your administrator role or a different account, fix the profile now. Everything downstream inherits this answer.

  4. Note the Region trap. A Region stored in the AWS profile applies to AWS CLI commands only. Both the AWS post and the Kimi providers page say Kimi Code needs AWS_REGION or AWS_DEFAULT_REGION set explicitly, in its own config or the shell, because it cannot infer a Region from ~/.aws/config. You set it in Step 3.

Why SSO rather than access keys in ~/.aws/credentials: AWS recommends short-term credentials over long-term ones, and the provider’s token lifetime is capped by the session. An SSO session that ends at the close of the workday takes Kimi’s Bedrock access with it, which is the property you want from an agent that can run shell commands.

Step 2: Attach an IAM policy scoped to one inference profile

A global cross-Region request is not authorized once. The global cross-Region inference page says Bedrock evaluates three resources: the inference profile in your source Region, the foundation model in your source Region, and a Region-agnostic global foundation model ARN, arn:aws:bedrock:::foundation-model/..., for which aws:RequestedRegion is unspecified. The bedrock:InferenceProfileArn condition key is populated for both foundation-model evaluations but not for the profile evaluation. Leave any of the three out of the policy and the request is denied.

Matrix chart titled One global request is authorized three times: rows for Inference profile ARN, Regional model ARN, Global model ARN and Bearer token call, with columns aws:RequestedRegion (us-east-1, us-east-1, unspecified, not stated) and bedrock:InferenceProfileArn (not populated, populated, populated, not stated).Matrix chart titled One global request is authorized three times: rows for Inference profile ARN, Regional model ARN, Global model ARN and Bearer token call, with columns aws:RequestedRegion (us-east-1, us-east-1, unspecified, not stated) and bedrock:InferenceProfileArn (not populated, populated, populated, not stated).
A global Kimi K3.1 request from us-east-1 is checked against the profile, the regional model and the Region-agnostic global model, and only the last carries aws:RequestedRegion unspecified; the bearer token call is gated by token type instead. Source: Amazon Bedrock global cross-Region inference docs and the AWS Machine Learning Blog, fetched Nov 20, 2026; us-east-1 is this guide's example Region.

The policy below is the AWS post’s Kimi policy reshaped into the three-part form that the global cross-Region inference page publishes, filled in for run:kimi-bedrock-01. It keeps the AWS post’s statement for short-term bearer tokens, its read permission on the profile and its two invoke actions, and it adds the aws:RequestedRegion conditions from the global page. If you prefer the AWS post’s policy exactly as published, it grants the same actions on the same ARNs without the Region conditions; replace ${AWS_REGION} and ${AWS_ACCOUNT_ID} in it with your values.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "BedrockShortTermBearerToken",
      "Effect": "Allow",
      "Action": "bedrock:CallWithBearerToken",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "bedrock:bearerTokenType": "SHORT_TERM"
        }
      }
    },
    {
      "Sid": "BedrockReadKimiK31InferenceProfile",
      "Effect": "Allow",
      "Action": "bedrock:GetInferenceProfile",
      "Resource": "arn:aws:bedrock:us-east-1:111122223333:inference-profile/global.moonshotai.kimi-k3.1"
    },
    {
      "Sid": "InvokeKimiGlobalProfileInSourceRegion",
      "Effect": "Allow",
      "Action": [
        "bedrock:InvokeModel",
        "bedrock:InvokeModelWithResponseStream"
      ],
      "Resource": "arn:aws:bedrock:us-east-1:111122223333:inference-profile/global.moonshotai.kimi-k3.1",
      "Condition": {
        "StringEquals": {
          "aws:RequestedRegion": "us-east-1"
        }
      }
    },
    {
      "Sid": "InvokeKimiRegionalModelThroughProfile",
      "Effect": "Allow",
      "Action": [
        "bedrock:InvokeModel",
        "bedrock:InvokeModelWithResponseStream"
      ],
      "Resource": "arn:aws:bedrock:us-east-1::foundation-model/moonshotai.kimi-k3.1",
      "Condition": {
        "StringEquals": {
          "aws:RequestedRegion": "us-east-1",
          "bedrock:InferenceProfileArn": "arn:aws:bedrock:us-east-1:111122223333:inference-profile/global.moonshotai.kimi-k3.1"
        }
      }
    },
    {
      "Sid": "InvokeKimiGlobalModelThroughProfile",
      "Effect": "Allow",
      "Action": [
        "bedrock:InvokeModel",
        "bedrock:InvokeModelWithResponseStream"
      ],
      "Resource": "arn:aws:bedrock:::foundation-model/moonshotai.kimi-k3.1",
      "Condition": {
        "StringEquals": {
          "aws:RequestedRegion": "unspecified",
          "bedrock:InferenceProfileArn": "arn:aws:bedrock:us-east-1:111122223333:inference-profile/global.moonshotai.kimi-k3.1"
        }
      }
    }
  ]
}

What each statement buys you:

Sid Resource Why the first run needs it
BedrockShortTermBearerToken * The provider authenticates with a short-term bearer token; the condition refuses long-term keys
BedrockReadKimiK31InferenceProfile The profile in us-east-1 Included in the AWS post’s policy for reading the profile definition
InvokeKimiGlobalProfileInSourceRegion The profile in us-east-1 First of the three evaluations; carries the source Region
InvokeKimiRegionalModelThroughProfile The model in us-east-1 Second evaluation; only reachable through this one profile
InvokeKimiGlobalModelThroughProfile arn:aws:bedrock:::foundation-model/moonshotai.kimi-k3.1 Third evaluation; the ARN with no Region or account is intentional and required for global routing

The bedrock:InferenceProfileArn condition is what makes the two foundation-model statements narrow: the prerequisites page describes it as the way to let a role invoke a model only through a named inference profile. Without it, the same role could call the model directly. The AWS post’s policy also contains a statement this guide leaves out, BedrockInvokeKimiK31DefaultProject. Added here it would be a sixth statement alongside the five above; in the AWS post’s published policy it is the fifth, because the post puts both foundation-model ARNs in a single statement. It allows bedrock:InvokeModel on arn:aws:bedrock:REGION:ACCOUNT:project/default with a bedrock:ModelArn condition. It is required only when a model uses the openai_responses protocol. Kimi’s default for moonshotai.* is Chat Completions, so leave it out unless you add protocol = "openai_responses" later.

Attach the policy:

  1. Save the JSON as kimi-bedrock-k31.json, replacing the account and Region if yours differ. Keep the Region identical in all four ARNs and both aws:RequestedRegion conditions that name it.
  2. Create a customer-managed policy from the file and attach it to the role behind dev-bedrock, following the AWS steps for adding IAM identity permissions that the prerequisites page links to. If dev-bedrock maps to an IAM Identity Center permission set, the administrator who owns that permission set adds the policy there.
  3. Remove broader Bedrock grants from the role if it was copied from a general-purpose one. The prerequisites page notes that the AmazonBedrockFullAccess managed policy already covers inference profiles, which means it would also hide whether your scoped policy is correct.
  4. Ask whoever owns your organization’s service control policies whether a Region-deny SCP applies to the account. Per the global page, an SCP that blocks unused Regions must either allow "aws:RequestedRegion": "unspecified" or exempt calls by bedrock:InferenceProfileArn; otherwise the third evaluation fails even though your IAM policy is correct. An SCP that explicitly denies global inference, which the same page documents for data-residency needs, cannot be fixed from your side.

Step 3: Write the bedrock provider into config.toml

The AWS post notes that Kimi Code’s desktop and web provider-creation screens do not expose every environment field this credential-chain setup uses, and the providers reference says the interactive /provider manager refuses proprietary protocols such as Amazon Bedrock when importing known third-party providers. Edit the file directly.

  1. Find the file. It is ~/.kimi-code/config.toml, or $KIMI_CODE_HOME/config.toml if you set KIMI_CODE_HOME.

  2. Back it up before changing anything:

    cp ~/.kimi-code/config.toml ~/.kimi-code/config.toml.bak
    
  3. Merge the block below into the file. Do not overwrite unrelated providers or models.

  4. Save the file, then continue to Step 4 before trusting it.

default_model = "bedrock-kimi-k3-1"

[providers.bedrock]
type = "bedrock"

[providers.bedrock.env]
AWS_REGION = "us-east-1"
AWS_PROFILE = "dev-bedrock"

[models.bedrock-kimi-k3-1]
provider = "bedrock"
model = "global.moonshotai.kimi-k3.1"
max_context_size = 1000000
capabilities = ["always_thinking", "thinking", "image_in", "tool_use"]

Kimi Code CLI documentation page titled Providers and models.
Kimi Code CLI documentation, "Providers and models", published by Moonshot AI: the configuration reference for provider types in config.toml, including the bedrock provider used in this guide. · Original source

Every line is a decision:

Line What it does Why this value
default_model = "bedrock-kimi-k3-1" Interactive kimi sessions start on this alias Saves passing --model each time; omit it if another provider should stay default
type = "bedrock" Selects the native provider from 2.7.0 The only type that mints tokens from the AWS credential chain
AWS_REGION = "us-east-1" Source Region and endpoint host Must match the Region in your IAM policy; the provider cannot read it from ~/.aws/config
AWS_PROFILE = "dev-bedrock" Picks the named profile from Step 1 Without it the provider uses the default chain, which may resolve a different identity
model = "global.moonshotai.kimi-k3.1" The Bedrock global inference profile ID Most current Bedrock models need a profile ID rather than the base model ID
max_context_size = 1000000 Declares a 1-million-token window Value from the AWS post’s example for this model
capabilities = [...] Tells Kimi what the model can do The AWS post says Kimi Code does not auto-detect capabilities for most Bedrock models, including Kimi

Three notes on this block. The [providers.bedrock.env] table supplies configuration to the provider only; the AWS post states it does not export variables into your shell, so aws commands in the same terminal still need --profile. The block deliberately contains no api_key, api_key_env or AWS_BEARER_TOKEN_BEDROCK, which is what makes the provider fall back to ambient credentials. And the capability list is a client-side declaration: the AWS post lists always_thinking, thinking, image_in and tool_use as supported for Kimi K3.1 Pro Highspeed and audio_in and video_in as unsupported. Declare only what the model card supports, and test tool and image workflows yourself rather than trusting the labels.

If your network forces Bedrock traffic through a VPC endpoint or another custom host, add base_url to the model table. Kimi uses a custom base_url verbatim, so it must include the wire path, /openai/v1 for Kimi’s Chat Completions route; the AWS post’s example uses a host of the form https://vpce-EXAMPLE-VPCEID.bedrock-runtime.us-west-2.vpce.amazonaws.com/openai/v1. Keep that host’s Region equal to AWS_REGION. For proxies and custom certificate authorities in front of coding agents, see the corporate proxy and CA certificate guide.

Step 4: Run the first headless prompt and check what it proves

A status light is not a test. The AWS post warns that the desktop and web apps can show a bedrock provider as connected without validating credentials, IAM permissions, Region, model access or the network path. Only a real request exercises all five.

  1. Prove that no key is configured. Both commands should print nothing:

    grep -nE 'api_key|AWS_BEARER_TOKEN_BEDROCK' ~/.kimi-code/config.toml
    env | grep -E '^AWS_BEARER_TOKEN_BEDROCK='
    

    The first command catches api_key, api_key_env and the env sub-table key anywhere in the file. The second is a hygiene check on the shell; see the section on undocumented behavior for why it is worth running.

  2. Send the AWS post’s test prompt in headless mode:

    kimi --model bedrock-kimi-k3-1 --prompt "Write a Python function that checks whether a string is a palindrome. Include a short usage example."
    

    Expected observation: the CLI streams a short function and a usage example, with no authentication, authorization, Region, model-access or network error.

  3. Start an interactive session in a project:

    cd /path/to/your/project
    kimi
    

    Because default_model is set, the session uses bedrock-kimi-k3-1. Ask it to explain the repository first. Review every proposed file change and shell command before approving it.

  4. Check the audit trail in the source Region. The global page says CloudTrail and CloudWatch keep recording in the Region you called from even when inference runs elsewhere. Open CloudTrail in us-east-1 and confirm the Bedrock calls carry the role ARN you saw in Step 1. The API keys page notes that keys travel in authorization headers and are not logged, so the identity on the event is your evidence of which principal made the call.

The setup is done when every box is checked:

  • [ ] The headless prompt streamed an answer through bedrock-kimi-k3-1.
  • [ ] The key search found no api_key, api_key_env or AWS_BEARER_TOKEN_BEDROCK in config, and none in the shell.
  • [ ] CloudTrail in us-east-1 shows the dedicated Kimi role, and no IAM user of the kind a long-term key creates.
  • [ ] The role holds only the five statements above, with no broad Bedrock managed policy beside them.

Worked example: run:kimi-bedrock-01 from login to failure drills

Running the failure cases on purpose, once, is cheaper than meeting them during a deadline. The table lists illustrative expected observations derived from the documentation, not a transcript of an executed run. Kimi and AWS do not publish exact error wording for these cases, so the expected result names the category of failure and what restores the run.

Input Action Expected result
run:kimi-bedrock-01 / login: profile dev-bedrock, SSO, account 111122223333 aws sso login --profile dev-bedrock, then aws sts get-caller-identity --profile dev-bedrock Browser sign-in completes; the identity output shows account 111122223333 and the dedicated Kimi role, not an administrator role
run:kimi-bedrock-01 / key check: config.toml from Step 3, clean shell Run the two key-search commands from Step 4 Both print nothing, so the provider must use the ambient credential chain for profile dev-bedrock
run:kimi-bedrock-01 / first prompt: alias bedrock-kimi-k3-1, AWS_REGION = "us-east-1" kimi --model bedrock-kimi-k3-1 --prompt "Write a Python function that checks whether a string is a palindrome. Include a short usage example." A palindrome function and usage example stream back with no authentication, Region, model-access or network error
run:kimi-bedrock-01 / drill A: InvokeKimiGlobalModelThroughProfile removed from the policy Rerun the same headless prompt after the policy change takes effect The request fails with an access-denied authorization error, because global routing needs all three parts; restoring the statement makes the prompt succeed again
run:kimi-bedrock-01 / drill B: AWS_REGION line commented out, no AWS_REGION or AWS_DEFAULT_REGION exported Rerun the same headless prompt The provider cannot resolve a Region and the run fails before any model call; the Region in ~/.aws/config does not help; uncommenting the line fixes it
run:kimi-bedrock-01 / drill C: AWS_REGION = "us-west-2" while the policy names us-east-1 Rerun the same headless prompt The request goes to the us-west-2 endpoint and is refused, since every policy ARN and the aws:RequestedRegion conditions name us-east-1; set the Region back
run:kimi-bedrock-01 / drill D: SSO session for dev-bedrock has expired Rerun the prompt, then aws sts get-caller-identity --profile dev-bedrock Both fail on credentials, because the provider cannot mint a token without a session; aws sso login --profile dev-bedrock restores both
run:kimi-bedrock-01 / drill E: drill A still applied, desktop app open on the same config Compare the provider list status with the headless prompt result The provider can still read connected while the prompt fails; only the prompt result counts as proof

Read the drills as a map of where responsibility sits. Drill A is pure IAM: the CLI, the token and the Region are all fine, and only the policy changed. Drill B never reaches AWS at all, which is why the error appears quickly and why no CloudTrail event records it. Drill C is the case people misdiagnose most, because the configuration looks valid and the profile is correct; the mismatch is between two files owned by different people, the TOML on the laptop and the policy in IAM. Drill D is the normal end of a workday, and the fix belongs to the person at the keyboard, not to an administrator.

Run the drills in a scratch directory, one at a time, and restore each change before starting the next. Write down what your terminal actually printed for each one next to this table; those lines become your team’s real troubleshooting reference, replacing the categories above.

Troubleshooting the failures you will actually hit

Start from the symptom, confirm the cause with one check, then change one thing.

Symptom Likely cause Confirm Fix
Access denied on every call Policy not attached to the role the profile resolves to Compare aws sts get-caller-identity --profile dev-bedrock with the role holding the policy Attach the policy to that role, or fix AWS_PROFILE
Access denied only through the global profile Global foundation-model statement missing, or its bedrock:InferenceProfileArn string differs from the profile ARN Diff the ARN strings character by character Restore the third statement with the exact profile ARN
Access denied although IAM looks right A Region-deny SCP blocks the unspecified evaluation Ask the SCP owner whether unspecified or an inference-profile exemption is allowed Update the SCP as the global page describes, or use a permitted profile
Denied in one Region, works in another AWS_REGION, a custom base_url host and the policy ARNs disagree Read all three values side by side Make all three name the same Region
Run fails before contacting AWS No Region resolvable Search the config for AWS_REGION; check the shell for AWS_REGION or AWS_DEFAULT_REGION Set AWS_REGION in [providers.bedrock.env]
Worked yesterday, fails today Session expired; the token cannot outlive it aws sts get-caller-identity --profile dev-bedrock fails too aws sso login --profile dev-bedrock
CloudTrail shows an unexpected identity A configured key overrides the credential chain The Step 4 key search finds a match Remove the key line, or move it into a deliberate rollback block
Model never uses thinking, images or tools Capabilities not declared Inspect the capabilities line Declare only what the model card supports
Works on Chat Completions, denied after switching to openai_responses Default-project permission missing Check for the project/default statement Add the AWS post’s default-project statement
Desktop says connected, prompts fail Status is a configuration indicator Run the headless prompt Diagnose from the prompt’s actual error

Two of these deserve a longer word. The SCP case is invisible from the laptop: your IAM simulator and your policy JSON both look correct, and the deny happens one layer up in AWS Organizations. If your organization explicitly denies global inference for data-residency reasons, the global page’s example matches "aws:RequestedRegion": "unspecified" together with an ArnLike on inference-profile/global.*, and no change on your side will get past it. The fix is a different profile that the model card lists, approved by whoever owns that policy.

The silent-key case matters because nothing fails. If someone adds api_key_env while testing and forgets it, Kimi keeps working, only now under whatever principal minted that key. That is why the done checklist pairs the config search with CloudTrail: one proves intent, the other proves what happened.

Rollback and kill switches

Plan the exits before you need them. Work down this list from least to most disruptive.

  1. Restore the previous configuration. If anything in Step 3 broke an existing setup, put the backup back:

    cp ~/.kimi-code/config.toml.bak ~/.kimi-code/config.toml
    
  2. Fall back to an explicit short-term key, same provider. If the credential chain is broken on one machine but Bedrock access is fine, add api_key_env = "KIMI_BEDROCK_KEY" under [providers.bedrock] and export a short-term key generated from the Bedrock console’s API keys page in us-east-1. The API keys page says a console-generated short-term key works only in the Region where it was generated and expires with the console session, at most 12 hours. Your policy’s SHORT_TERM condition already permits it. Remove the line when the chain works again.

  3. Return to the pre-2.7.0 provider type. The AWS post describes the older path as a type = "openai" provider with the regional base_url and a Bedrock API key. The post does not print that configuration, so the block below is assembled from fields the Kimi providers page documents: the regional bedrock-runtime host plus the /openai/v1 wire path, and api_key_env naming the variable that holds the key. Confirm the model ID on the model card before relying on it.

    [providers.bedrock-legacy]
    type = "openai"
    base_url = "https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1"
    api_key_env = "KIMI_BEDROCK_KEY"
    
    [models.bedrock-legacy-kimi]
    provider = "bedrock-legacy"
    model = "global.moonshotai.kimi-k3.1"
    max_context_size = 1000000
    capabilities = ["always_thinking", "thinking", "image_in", "tool_use"]
    

    A long-term key would also need the LONG_TERM token type allowed, which the policy above refuses on purpose. Prefer a short-term key here too.

  4. Stop all bearer-token use by the role. The API key permissions page documents a deny for short-term keys on both the Bedrock and Bedrock Mantle endpoints. Because the native provider authenticates with short-term bearer tokens, attaching this to the Kimi role stops it at once, whatever the laptop’s configuration says:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Deny",
          "Action": "bedrock:CallWithBearerToken",
          "Resource": "*",
          "Condition": {
            "StringEquals": {
              "bedrock:bearerTokenType": "SHORT_TERM"
            }
          }
        },
        {
          "Effect": "Deny",
          "Action": "bedrock-mantle:CallWithBearerToken",
          "Resource": "*",
          "Condition": {
            "StringEquals": {
              "bedrock-mantle:bearerTokenType": "SHORT_TERM"
            }
          }
        }
      ]
    }
    

    The same page warns that you cannot prevent generation of short-term keys, only their use. For a suspected leak, the API keys page lists two responses for short-term keys: invalidate the session that generated the key, or attach a policy denying CallWithBearerToken.

  5. Harden instead of stopping. To keep the native provider working while making sure nobody slips a long-lived key into the loop, attach the page’s deny for LONG_TERM on both actions instead. The allow statement in Step 2 already conditions on SHORT_TERM; the explicit deny survives someone later adding a broad allow.

  6. Clean up after a trial. The AWS post reminds you to delete any IAM identity or permissions created for testing. Deleting config.toml, the AWS CLI profile or the CLIs themselves does not revoke IAM permissions or an active AWS session. If you are retiring older Bedrock API keys across a team at the same time, the API key migration drill describes a rehearsal pattern you can adapt.

What the official documentation does not settle

The steps above follow documented behavior. These points are not settled by the selected sources, so treat them as open and verify them on your own machine.

  • Shell-exported bearer tokens. The Kimi providers page lists api_key, api_key_env and AWS_BEARER_TOKEN_BEDROCK in the env sub-table as key sources, and says the CLI generally does not fall back to shell variables for credentials except through api_key_env. It does not say whether the AWS token library inside the provider would read an AWS_BEARER_TOKEN_BEDROCK already exported in your shell. That is why Step 4 checks the shell as well as the file.
  • Token Region with a custom endpoint. Short-term keys are Region-bound. The documents do not say which Region the provider generates its token for when base_url names a different Region from AWS_REGION. Keep them equal and the question never arises.
  • Error text. Neither Kimi nor AWS publishes the exact messages for the drills, so the table describes categories. Record your own.
  • Source Region support. us-east-1 is this guide’s illustrative choice. Whether it is a supported source Region for Kimi K3.1 Pro Highspeed is a model-card question that changes over time.
  • Which credential won. No documented CLI command reports whether a given request used the ambient chain or a configured key. The config search plus the CloudTrail identity is the practical substitute.

Sources

YOU'RE THROUGH THIS ONE.

Keep connecting the dots.

Back to the library

Many assistants.
One place to remember.

Bring your AI sessions, context, and usage together with Automater.

Meet Automater