Initial commit

This commit is contained in:
Leo 2025-11-14 21:24:51 +02:00
commit 4f57a52163
2 changed files with 33 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.env

32
main.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
source .env
PROMPT="$*"
TEMP_FILE=$(mktemp)
prompt=$(echo $PROMPT)
JSON_PAYLOAD=$(jq -n \
--arg model "claude-sonnet-4-5-20250929" \
--arg prompt "$PROMPT" \
'{
model: $model,
max_tokens: 1024,
messages: [{role: "user", content: $prompt}]
}')
# Show loading message
echo -ne "\033[36mFetching response from Claude...\033[0m"
curl -s https://api.anthropic.com/v1/messages \
--header "x-api-key: $ANTHROPIC_API_KEY" \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--data "$JSON_PAYLOAD" > "$TEMP_FILE"
# Clear loading message
echo -ne "\r\033[K"
# Display response
jq -r '.content[0].text' "$TEMP_FILE"
rm "$TEMP_FILE"