Code Examples

Ready-to-use code examples in popular programming languages.

JavaScript / Node.js

// JavaScript Example
const API_KEY = process.env.PANDALINK_API_KEY;
const API_URL = 'https://api.pandalink.ai/v1/chat/completions';

async function chat(message) {
  const response = await fetch(API_URL, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'qwen3-14b',
      messages: [{ role: 'user', content: message }],
    }),
  });
  
  const data = await response.json();
  return data.choices[0].message.content;
}

chat('Hello!').then(console.log);

Python

# Python Example
import os
import requests

API_KEY = os.environ.get('PANDALINK_API_KEY')
API_URL = 'https://api.pandalink.ai/v1/chat/completions'

def chat(message):
    headers = {
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json',
    }
    
    data = {
        'model': 'qwen3-14b',
        'messages': [{'role': 'user', 'content': message}]
    }
    
    response = requests.post(API_URL, headers=headers, json=data)
    return response.json()['choices'][0]['message']['content']

print(chat('Hello!'))

cURL

# Basic Chat Request
curl -X POST https://api.pandalink.ai/v1/chat/completions \
  -H "Authorization: Bearer ak_live_demo_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-14b",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

Common Use Cases

Chatbot

Build conversational AI interfaces

Content Generation

Automate writing and content creation

Code Assistance

AI-powered coding help and debugging

Customer Support

Intelligent automated responses