Closed RealAlexandreAI closed 4 months ago
A custom domain is not necessary. You can use the default *.workers.dev domain to access it.
The API format of this project is identical to the Anthropic API. (https://docs.anthropic.com/en/api/messages)
For example:
curl -sS -D - https://worker.xxx.workers.dev/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $API_KEY_VARIABLE" \
-d '{
"model": "claude-3-opus-20240229",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"stream": false,
"max_tokens": 512
}'
Replace the URL with your deployed worker URL and $API_KEY_VARIABLE with the value of the API_KEY variable you defined.
cURL example at Windows 10 cmd terminal, UUUUUUUU is your site url of cloudflare workers, KKKKKKKK is your api-key:
curl -sS -D - https://UUUUUUUU/v1/messages ^
-H "Content-Type: application/json" ^
-H "x-api-key: KKKKKKKK" ^
-d "{\"model\": \"claude-3-5-sonnet-20240620\", \"stream\": false, \"max_tokens\": 512, \"messages\": [{\"role\": \"user\", \"content\": \"Hello, Claude. How are you today?\"}]}"
you weill get reponse as below:
...
{"id":"msg_xxxxxxxxx","type":"message","role":"assistant","model":"claude-3-5-sonnet-20240620","content":[{"type":"text","text":"Hello! I'm doing well, thank you for asking. How are you doing today? Is there anything I can assist you with?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":16,"output_tokens":30}}
Thank you for your project. Could you provide an example of cURL? Also, is a custom domain necessary?