| """ | |
| 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) | |