Using the Proxy results in a 404
Any help being able to see the request Claude uses as I am getting a 404 and i would like to see the url and api request claude is using to access my AWS Bedrock claude model.
Note my url and request works in curl and postman. for example:
curl --request POST \
--url https://my-company-url-api-endpoint/bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0 \
--header 'Authorization: Bearer {{BearerToken}}' \
--header 'content-type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"text": "Give me joke"
}
]
}
],
"system": [
{
"text": "You are a helpful assistant."
}
]
}'
I have a get_proxy_token.sh file which successfully gets a Bearer token ok. For example I can run:
~/.claude/get_proxy_token.sh
and it echos the token and sets the ACCESS_TOKEN env variable.
In my Claude settings.json (/Users/me/.claude/settings.json) I have the following settings:
{
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"ANTHROPIC_BEDROCK_BASE_URL": "https://my-company-url-api-endpoint/bedrock/",
"CLAUDE_CODE_SKIP_BEDROCK_AUTH": "1",
"ANTHROPIC_MODEL": "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
},
"apiKeyHelper": "/Users/me/.claude/get_proxy_token.sh",
"CLAUDE_CODE_API_KEY_HELPER_TTL_MS": 3600000
}
Claude output in terminal:
> summarise this project
⎿ API Error: 404 Resource not found
I have tried adding --verbose and --debug flags when running claude code but i cannot see the output anywhere.
Any ideas why this might not be working and how I can debug it?
EDIT:
2 things. Claude code is adding _/invoke_ or _/invoke-with-stream_ to the url path at the end. I had to account for this in my api gateway as it was giving a 404.
However:
I added the following line to my shell script which gets the token:
echo "Script called at $(date)" >> /tmp/proxy_token_called.log
I can tell that claude code is not calling my apiKeyHelper file as the log is out output to the tmp file. It does output when I manually run the .sh file. The path is correct and it the script is executable.
Any ideas why claude is not running this file?
12 Comments
Try setting env vars
ANTHROPIC_LOG=debug DEBUG=1to see the requests going out.Run the
/statuscommand and it should tell you whether theapiKeyHelperis being used - you want it to be used for "Auth token", since you're trying to setAuthorization: Bearer. Generally if there is anANTHROPIC_AUTH_TOKENenv var set, that will take precedence over theapiKeyHelper.QQ
does the settings files need to be
.settings.jsonorsettings.json(no dot) -> the latter seemed to have fixed it?Is it possible to stop claude code from streaming requests and responses? When i type a query it fires off requests for every letter almost
I tried this in the settings:
"outputFormat": "json"But claude code is erroring on the response:
API Error: Cannot read properties of undefined (reading 'map')
Our API Gateway doesn't support streaming responses due to logging requirements.
It also tries to call:
/bedrock/model/us.anthropic.claude-3-5-haiku-20241022-v1:0/invoke-with-response-streameven thought I have:
"ANTHROPIC_MODEL": "us.anthropic.claude-3-7-sonnet-20250219-v1:0"in the settings json.
Thanks
Hey @sterankin, hope this info is helpful:
.ANTHROPIC_SMALL_FAST_MODELDISABLE_NON_ESSENTIAL_MODEL_CALLSWe don't currently support disabling streaming currently, though there should be a fallback to non-streaming after failure. Do you think the
API Error: Cannot read properties of undefined (reading 'map')is related to the gateway not handling streaming?Also, can you provide more information about:
Is this a custom API gateway or something off-the-shelf? What's preventing the SSE responses from being logged?
I'm not sure about the map error I think it could be due to the format difference between anthropics API response and the response from the AWS converse format for Claude.
For example this is an example response from Bedrock Claude:
This is Claudes normal response:
The map error might be due to the missing
"type": "text",In the Bedrock response?
With regards to our custom APi. We use an Azure API Gateway which proxies requests. The XML based structure of the APIM doesn't support streaming responses as the logging requires the complete response (to log token usages and complete response text etc).
Streaming responses use Server-Sent Events (SSE) which support only one subscriber. This creates a challenge when using APIM's Event Hub Logger as it would consume the stream, preventing the actual client from receiving the response.
Is your Gateway transforming the responses, or directly responding with what Bedrock sends? We do support Bedrock, as you can see if you connect directly (without proxy).
I can't currently speak to plans to disable streaming entirely, but do appreciate understanding the context you're working in.
This is the error i am seeing:
This is the response that comes back from our API Gateway - perhaps the issue is here but since "output" is at the top level then it should parse ok afaik. We don't modify the response at all, however we do wrap the Bedrock response in an API Gateway response object structure instead of returning the raw Bedrock response.
We then pull the "body" out of the response from AWS in our APIM:
<set-body>@(((JObject)context.Variables["originalBody"])["body"].ToString())</set-body>Response:
According to the AWS docs, the
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format
Additionally is it possible to set custom headers. For example we use AWS Guardrails and we allow some clients to override the severity with a header, but this causes Claude Code to error e.g.
"ANTHROPIC_CUSTOM_HEADERS": "{\"Guardrails\": \"low\"}",
with
API Error: Headers.delete: "{"Guardrails"" is an invalid header name.Wrapping in
outputis likely the issue. The response needs to look like this: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-request-response.html.ANTHROPIC_CUSTOM_HEADERSshould be incurl-style format (Name: Value) with newline separation for multiple. I'll see if we can update these docs to call out the newline requirement.@ant-kurt
it could be caused by the fact that the AWS Bedrock converse format is different to the Anthropic Claude format:
https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html#conversation-inference-call-response
I assume this is the problem and Claude code doesn't handle the Converse command response?
More details on converse:
https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html
@sterankin I was wondering if you found a solution to this. I think I encounter a similar error: I can query models via a test Python script but encounter the error below when I run it via Claude Code.
I think the issue is that my Python script works with
anthropic.claude-3-5-haiku-20241022-v1:0for example, but throws the same error if I queryus.anthropic.claude-3-5-haiku-20241022-v1:0oranthropic.claude-3-5-haiku-20241022-v1:0/invoke-with-response-stream. The CC request default includes the/invoke-with-response-streamsuffix, even if I override theus.prefix.This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Closing as this issue is likely stale. Please re-open if this is still happening. Thanks!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.