Skip to content

Instantly share code, notes, and snippets.

@jeansymolanza
Last active February 4, 2025 13:13
Show Gist options
  • Save jeansymolanza/3a19136d8c729ddcacf63a6422e1c95d to your computer and use it in GitHub Desktop.
Save jeansymolanza/3a19136d8c729ddcacf63a6422e1c95d to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define the API endpoint and headers
API_HOST="http://localhost:11434"
HEADERS=(
"-H" "Content-Type: application/json"
"-H" "x-some-header: some-value"
)
# Define the JSON payload
JSON_PAYLOAD='{
"model": "llama3.2",
"messages": [
{
"role": "user",
"content": "Why is the sky blue?"
}
]
}'
# Send the request using curl
response=$(curl -s -X POST "$API_HOST/api/chat" "${HEADERS[@]}" -d "$JSON_PAYLOAD")
# Print the response
echo "$response"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment