File size: 876 Bytes
4bf8a6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
GPT-5.2 API Example via NexaAPI
Get your free API key at: https://nexa-api.com
Install: pip install nexaapi
"""
from nexaapi import NexaAPI

# Initialize client - get your key at https://nexa-api.com
client = NexaAPI(api_key='YOUR_API_KEY')

# Basic text generation
response = client.chat.completions.create(
    model='gpt-5.2',
    messages=[
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'Explain quantum computing in simple terms'}
    ]
)
print("GPT-5.2 Response:")
print(response.choices[0].message.content)

# Coding example
code_response = client.chat.completions.create(
    model='gpt-5.2',
    messages=[{
        'role': 'user',
        'content': 'Write a Python function to sort a list of dictionaries by a key'
    }]
)
print("\nCode Generation:")
print(code_response.choices[0].message.content)