!API-Key Tester for Mistral AI using CURL

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > !API-Key Tester for CURL-Command >

!API-Key Tester for Mistral AI using CURL

 

To test the validity of your Mistral AI API key aside from using SPR, you can use CURL.

 

1. Insert your Mistral AI API key into the SPR script below at the `$$KEY` variable.

2. Run this SPR script.

It will generate a CURL command-line script and copy it to the clipboard.

3. Open a Command Prompt (CMD) console, paste the clipboard contents, and press "ENTER" to execute.

 

 

' Insert your Mistral API-Key here

$$KEY=Nf8He53489fj2382934tr3hf3724

 

' Start building the curl command

$$TTX=curl -X POST https://api.mistral.ai/v1/chat/completions

 

' Add API key header with $$KEY (Mistral uses x-api-key)

$$TTX+ -H "x-api-key: $$KEY"

 

' Add Content-Type header

$$TTX+ -H "Content-Type: application/json"

 

' Add the JSON payload (escaped quotes for JSON inside the string)

$$TTX+ -d "{\"model\": \"mistral-small-latest\", \"messages\": [{\"role\": \"user\", \"content\": \"

$$TTX+Hello, are you there?\"}]}"

 

' Execute the curl command in a Windows CMD-Window

CLB.Set Ansi Text|$$TTX

 

' End script

ENR.

 

clip1087

 

 

Running the generated CURL script from the clipboard in a CMD console will display this result if the API key is valid.