cURL Examples

โš ๏ธ BETA: Our API is in beta. Share your feedback!

Command-line examples for GMTech's API using cURL.

Basic Chat

curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key gmtech_your_api_key" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is cURL?"}
    ]
  }'

Different Models

OpenAI GPT-4

curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Claude

curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "claude-sonnet-46",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Gemini

curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "google-gemini-25-pro",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Image Generation

curl https://app.gmtech.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A futuristic city",
    "size": "1024x1024"
  }'

Sentiment Analysis

curl -X POST https://app.gmtech.com/v1/sentiment \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{"text": "I love this product!"}'

Example response:

{
  "sentiment": {
    "Positive": 90, "Negative": 5, "Neutral": 5,
    "Joyful": 85, "Angry": 0, "Sad": 2,
    "Surprised": 15, "Confident": 80, "Anxious": 3, "Confused": 0
  },
  "model": "gpt-4o-mini"
}

List Available Models

curl https://app.gmtech.com/v1/models \
  -H "Authorization: Api-Key $GMTECH_API_KEY"

Using Environment Variable

# Set your API key
export GMTECH_API_KEY="gmtech_your_api_key"

# Use in requests
curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Pretty JSON Output

curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }' | jq '.'

Save to File

curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }' -o response.json

Error Handling

# Check response status
curl -w "%{http_code}" https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Shell Script Example

#!/bin/bash

# chat.sh - Simple GMTech API script
GMTECH_API_KEY="gmtech_your_key"
MODEL="${1:-gpt-4o-mini}"
MESSAGE="${2:-Hello!}"

curl https://app.gmtech.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key $GMTECH_API_KEY" \
  -d "{
    \"model\": \"$MODEL\",
    \"messages\": [{\"role\": \"user\", \"content\": \"$MESSAGE\"}]
  }" | jq -r '.choices[0].message.content'

# Usage: ./chat.sh gpt-4o "What is AI?"

Next Steps


Need help? Contact support

results matching ""

    No results matching ""