I'm running a prototype locally and keep getting error: TypeError: Failed to fetch (see below).
Error: Connection error.
at Anthropic.makeRequest (core.mjs:297:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)Caused by: TypeError: Failed to fetch
at Anthropic.fetchWithTimeout (core.mjs:354:1)
at Anthropic.makeRequest (core.mjs:286:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)
AIWriter2.vue:150 Connection error.
The code and api key look fine. I have a similar test with OpenAI and no connection errors, it works fine.
I can also call Anthropic aok via a server function.
Unsure why this local call is giving me so much grief.
Setup looks fine, all the headers should be set automatically according to the docs.
.env file has ANTHROPIC_API_KEY = ""
and code is
const anthropic = new Anthropic({
apiKey: process.env['ANTHROPIC_API_KEY'], // This is the default and can be omitted
});
No errors on setup.
But the call
const message = await anthropic.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: aiprompt.value }],
model: "claude-3-haiku-20240307",
});
just keeps giving me
Error: Connection error.
at Anthropic.makeRequest (core.mjs:297:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)Caused by: TypeError: Failed to fetch
at Anthropic.fetchWithTimeout (core.mjs:354:1)
at Anthropic.makeRequest (core.mjs:286:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)
AIWriter2.vue:150 Connection error.
What's up with that?
Is there some restriction on connecting from local development?
I'm running a prototype locally and keep getting error: TypeError: Failed to fetch (see below).
Error: Connection error.
at Anthropic.makeRequest (core.mjs:297:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)Caused by: TypeError: Failed to fetch
at Anthropic.fetchWithTimeout (core.mjs:354:1)
at Anthropic.makeRequest (core.mjs:286:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)
AIWriter2.vue:150 Connection error.
The code and api key look fine. I have a similar test with OpenAI and no connection errors, it works fine.
I can also call Anthropic aok via a server function.
Unsure why this local call is giving me so much grief.
Setup looks fine, all the headers should be set automatically according to the docs.
.env file has ANTHROPIC_API_KEY = ""
and code is
const anthropic = new Anthropic({
apiKey: process.env['ANTHROPIC_API_KEY'], // This is the default and can be omitted
});
No errors on setup.
But the call
const message = await anthropic.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: aiprompt.value }],
model: "claude-3-haiku-20240307",
});
just keeps giving me
Error: Connection error.
at Anthropic.makeRequest (core.mjs:297:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)Caused by: TypeError: Failed to fetch
at Anthropic.fetchWithTimeout (core.mjs:354:1)
at Anthropic.makeRequest (core.mjs:286:1)
at async Proxy.sendPrompt (AIWriter2.vue:132:1)
AIWriter2.vue:150 Connection error.
What's up with that?
Is there some restriction on connecting from local development?