File size: 784 Bytes
43235e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations
import json
import random
from pathlib import Path
from typing import Dict, Any, List, Optional
import requests

# ================= 基本配置 =================
NIM_API_KEY = "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"
NIM_ENDPOINT = "https://integrate.api.nvidia.com/v1/chat/completions"
MODEL_NAME = "meta/llama-3.2-90b-vision-instruct"

headers = {
    "Authorization": f"Bearer {NIM_API_KEY}",
    "Content-Type": "application/json",
}
payload = {
    "model": MODEL_NAME,
    "messages": [
        {"role": "user", "content": "用一句话介绍一下你自己。"}
    ],
    "max_tokens": 64,
}
r = requests.post(NIM_ENDPOINT, headers=headers, json=payload, timeout=30)
print(r.status_code)
print(r.text[:500])