Get an API key

To use the API, you need an API key. You can create a key with one click in MakerSuite.

Get an API key

Verify your API key with curl command

You can use a curl command to verify your setup. You can pass the API key either in the URL:

PALM_KEY="YOUR KEY HERE"
curl -H 'Content-Type: application/json' \
     -d '{"prompt": {text: "Give me five subcategories of jazz"} }' \
     "https://generativelanguage.googleapis.com/v1/models/text-bison-001:generateText?key=${PALM_KEY}"

Or in the x-goog-api-key header:

PALM_KEY="YOUR KEY HERE"
curl -H 'Content-Type: application/json' \
     -H "x-goog-api-key: ${PALM_KEY}" \
     -d '{"prompt": {text: "Give me five subcategories of jazz"} }' \
     "https://generativelanguage.googleapis.com/v1/models/text-bison-001:generateText"

Next steps