1+ import os
2+ import requests
3+
4+ RUNPOD_TOKEN = os .environ ["RUNPOD_API_KEY" ] # 환경변수로 넣는 걸 추천
5+ URL = "https://rest.runpod.io/v1/pods"
6+
7+ headers = {
8+ "Authorization" : f"Bearer { RUNPOD_TOKEN } " ,
9+ "Content-Type" : "application/json" ,
10+ }
11+
12+ payload = {
13+ "allowedCudaVersions" : ["13.0" ],
14+ "cloudType" : "SECURE" ,
15+ "computeType" : "GPU" ,
16+ "containerDiskInGb" : 50 ,
17+ "containerRegistryAuthId" : "" ,
18+ # "countryCodes": ["KR"], # 예: 필요하면 실제 값으로
19+ # "cpuFlavorIds": ["cpu3c"], # GPU면 보통 불필요/자동인 경우도 있음 (스펙 확인)
20+ "cpuFlavorPriority" : "availability" ,
21+ "dataCenterIds" : [
22+ "EU-RO-1" ,"CA-MTL-1" ,"EU-SE-1" ,"US-IL-1" ,"EUR-IS-1" ,"EU-CZ-1" ,"US-TX-3" ,"EUR-IS-2" ,
23+ "US-KS-2" ,"US-GA-2" ,"US-WA-1" ,"US-TX-1" ,"CA-MTL-3" ,"EU-NL-1" ,"US-TX-4" ,"US-CA-2" ,
24+ "US-NC-1" ,"OC-AU-1" ,"US-DE-1" ,"EUR-IS-3" ,"CA-MTL-2" ,"AP-JP-1" ,"EUR-NO-1" ,"EU-FR-1" ,
25+ "US-KS-3" ,"US-GA-1"
26+ ],
27+ "dataCenterPriority" : "availability" ,
28+ "dockerEntrypoint" : [],
29+ "dockerStartCmd" : [],
30+ "env" : {"ENV_VAR" : "value" },
31+ "globalNetworking" : False ,
32+ "gpuCount" : 1 ,
33+ "gpuTypeIds" : ["NVIDIA GeForce RTX 4090" ],
34+ "gpuTypePriority" : "availability" ,
35+ "imageName" : "jinsoo1218/vllm-pod:latest" ,
36+ "interruptible" : False ,
37+ "locked" : False ,
38+ "minDiskBandwidthMBps" : 123 ,
39+ "minDownloadMbps" : 123 ,
40+ "minRAMPerGPU" : 8 ,
41+ "minUploadMbps" : 123 ,
42+ "minVCPUPerGPU" : 2 ,
43+ "name" : "vllm-pod" ,
44+ "networkVolumeId" : "2kn4qj6rql" , # <-- 여기 실제 ID로
45+ "ports" : ["8888/http" , "22/tcp" ],
46+ "supportPublicIp" : True ,
47+ "vcpuCount" : 2 ,
48+ "volumeInGb" : 20 ,
49+ "volumeMountPath" : "/workspace" ,
50+ }
51+
52+ resp = requests .post (URL , headers = headers , json = payload , timeout = 60 )
53+ print ("status:" , resp .status_code )
54+
55+ # 에러면 원인 보기 좋게
56+ try :
57+ data = resp .json ()
58+ except Exception :
59+ print (resp .text )
60+ raise
61+
62+ print (data )
63+
64+ # 실패 시 예외
65+ resp .raise_for_status ()
0 commit comments