当前位置:   article > 正文

怎样查看自己的chatgpt apikey可以调用哪些gpt模型?Python代码示例_写段python代码,测试gptkey是否可用

写段python代码,测试gptkey是否可用

大家好,我是淘小白~

最近在测试chatgpt api接口的时候,用到了3.5和4.0的apikey,因为模型要自定义,所以,就需要对两个类型的apikey  进行测试,在测试时候,3.5的apikey 还好,但是很多4.0的apikey ,很多问题没有遇到过,比如,查看4.0apikey 能够调用哪些模型,不同组织给的4.0apikey 好像还有一些差异,在测试的过程中,使用Python查看自己的apikey , 能调用哪些模型,让我们来看下Python方法。

1、安装openai库

pip install openai

安装库如果让你升级,就升级一下,现在好像是28的版本,我记得之前升级是27版本。

2、检查能调用哪些模型示例代码

  1. openai.api_key = 'sk-********************'
  2. # 上面的apikey 换成自己的
  3. models=openai.Model.list()
  4. print(models)

这样就可以查看哪些模型可以调用了。

3、得到的返回结果

  1. {
  2. "object": "list",
  3. "data": [
  4. {
  5. "id": "text-search-babbage-doc-001",
  6. "object": "model",
  7. "created": 1651172509,
  8. "owned_by": "openai-dev"
  9. },
  10. {
  11. "id": "gpt-3.5-turbo-16k",
  12. "object": "model",
  13. "created": 1683758102,
  14. "owned_by": "openai-internal"
  15. },
  16. {
  17. "id": "curie-search-query",
  18. "object": "model",
  19. "created": 1651172509,
  20. "owned_by": "openai-dev"
  21. },
  22. {
  23. "id": "text-davinci-003",
  24. "object": "model",
  25. "created": 1669599635,
  26. "owned_by": "openai-internal"
  27. },
  28. {
  29. "id": "text-search-babbage-query-001",
  30. "object": "model",
  31. "created": 1651172509,
  32. "owned_by": "openai-dev"
  33. },
  34. {
  35. "id": "babbage",
  36. "object": "model",
  37. "created": 1649358449,
  38. "owned_by": "openai"
  39. },
  40. {
  41. "id": "babbage-search-query",
  42. "object": "model",
  43. "created": 1651172509,
  44. "owned_by": "openai-dev"
  45. },
  46. {
  47. "id": "text-babbage-001",
  48. "object": "model",
  49. "created": 1649364043,
  50. "owned_by": "openai"
  51. },
  52. {
  53. "id": "text-similarity-davinci-001",
  54. "object": "model",
  55. "created": 1651172505,
  56. "owned_by": "openai-dev"
  57. },
  58. {
  59. "id": "davinci-similarity",
  60. "object": "model",
  61. "created": 1651172509,
  62. "owned_by": "openai-dev"
  63. },
  64. {
  65. "id": "code-davinci-edit-001",
  66. "object": "model",
  67. "created": 1649880484,
  68. "owned_by": "openai"
  69. },
  70. {
  71. "id": "curie-similarity",
  72. "object": "model",
  73. "created": 1651172510,
  74. "owned_by": "openai-dev"
  75. },
  76. {
  77. "id": "babbage-search-document",
  78. "object": "model",
  79. "created": 1651172510,
  80. "owned_by": "openai-dev"
  81. },
  82. {
  83. "id": "curie-instruct-beta",
  84. "object": "model",
  85. "created": 1649364042,
  86. "owned_by": "openai"
  87. },
  88. {
  89. "id": "text-search-ada-doc-001",
  90. "object": "model",
  91. "created": 1651172507,
  92. "owned_by": "openai-dev"
  93. },
  94. {
  95. "id": "davinci-instruct-beta",
  96. "object": "model",
  97. "created": 1649364042,
  98. "owned_by": "openai"
  99. },
  100. {
  101. "id": "gpt-3.5-turbo-instruct",
  102. "object": "model",
  103. "created": 1692901427,
  104. "owned_by": "system"
  105. },
  106. {
  107. "id": "text-similarity-babbage-001",
  108. "object": "model",
  109. "created": 1651172505,
  110. "owned_by": "openai-dev"
  111. },
  112. {
  113. "id": "text-search-davinci-doc-001",
  114. "object": "model",
  115. "created": 1651172505,
  116. "owned_by": "openai-dev"
  117. },
  118. {
  119. "id": "gpt-3.5-turbo-instruct-0914",
  120. "object": "model",
  121. "created": 1694122472,
  122. "owned_by": "system"
  123. },
  124. {
  125. "id": "babbage-similarity",
  126. "object": "model",
  127. "created": 1651172505,
  128. "owned_by": "openai-dev"
  129. },
  130. {
  131. "id": "text-embedding-ada-002",
  132. "object": "model",
  133. "created": 1671217299,
  134. "owned_by": "openai-internal"
  135. },
  136. {
  137. "id": "davinci-search-query",
  138. "object": "model",
  139. "created": 1651172505,
  140. "owned_by": "openai-dev"
  141. },
  142. {
  143. "id": "text-similarity-curie-001",
  144. "object": "model",
  145. "created": 1651172507,
  146. "owned_by": "openai-dev"
  147. },
  148. {
  149. "id": "text-davinci-001",
  150. "object": "model",
  151. "created": 1649364042,
  152. "owned_by": "openai"
  153. },
  154. {
  155. "id": "text-search-davinci-query-001",
  156. "object": "model",
  157. "created": 1651172505,
  158. "owned_by": "openai-dev"
  159. },
  160. {
  161. "id": "ada-search-document",
  162. "object": "model",
  163. "created": 1651172507,
  164. "owned_by": "openai-dev"
  165. },
  166. {
  167. "id": "ada-code-search-code",
  168. "object": "model",
  169. "created": 1651172505,
  170. "owned_by": "openai-dev"
  171. },
  172. {
  173. "id": "babbage-002",
  174. "object": "model",
  175. "created": 1692634615,
  176. "owned_by": "system"
  177. },
  178. {
  179. "id": "davinci-002",
  180. "object": "model",
  181. "created": 1692634301,
  182. "owned_by": "system"
  183. },
  184. {
  185. "id": "davinci-search-document",
  186. "object": "model",
  187. "created": 1651172509,
  188. "owned_by": "openai-dev"
  189. },
  190. {
  191. "id": "curie-search-document",
  192. "object": "model",
  193. "created": 1651172508,
  194. "owned_by": "openai-dev"
  195. },
  196. {
  197. "id": "babbage-code-search-code",
  198. "object": "model",
  199. "created": 1651172509,
  200. "owned_by": "openai-dev"
  201. },
  202. {
  203. "id": "text-search-ada-query-001",
  204. "object": "model",
  205. "created": 1651172505,
  206. "owned_by": "openai-dev"
  207. },
  208. {
  209. "id": "code-search-ada-text-001",
  210. "object": "model",
  211. "created": 1651172507,
  212. "owned_by": "openai-dev"
  213. },
  214. {
  215. "id": "gpt-3.5-turbo-16k-0613",
  216. "object": "model",
  217. "created": 1685474247,
  218. "owned_by": "openai"
  219. },
  220. {
  221. "id": "babbage-code-search-text",
  222. "object": "model",
  223. "created": 1651172509,
  224. "owned_by": "openai-dev"
  225. },
  226. {
  227. "id": "code-search-babbage-code-001",
  228. "object": "model",
  229. "created": 1651172507,
  230. "owned_by": "openai-dev"
  231. },
  232. {
  233. "id": "ada-search-query",
  234. "object": "model",
  235. "created": 1651172505,
  236. "owned_by": "openai-dev"
  237. },
  238. {
  239. "id": "ada-code-search-text",
  240. "object": "model",
  241. "created": 1651172510,
  242. "owned_by": "openai-dev"
  243. },
  244. {
  245. "id": "tts-1-hd",
  246. "object": "model",
  247. "created": 1699046015,
  248. "owned_by": "system"
  249. },
  250. {
  251. "id": "text-search-curie-query-001",
  252. "object": "model",
  253. "created": 1651172509,
  254. "owned_by": "openai-dev"
  255. },
  256. {
  257. "id": "text-davinci-002",
  258. "object": "model",
  259. "created": 1649880484,
  260. "owned_by": "openai"
  261. },
  262. {
  263. "id": "text-davinci-edit-001",
  264. "object": "model",
  265. "created": 1649809179,
  266. "owned_by": "openai"
  267. },
  268. {
  269. "id": "code-search-babbage-text-001",
  270. "object": "model",
  271. "created": 1651172507,
  272. "owned_by": "openai-dev"
  273. },
  274. {
  275. "id": "tts-1-hd-1106",
  276. "object": "model",
  277. "created": 1699053533,
  278. "owned_by": "system"
  279. },
  280. {
  281. "id": "ada",
  282. "object": "model",
  283. "created": 1649357491,
  284. "owned_by": "openai"
  285. },
  286. {
  287. "id": "text-ada-001",
  288. "object": "model",
  289. "created": 1649364042,
  290. "owned_by": "openai"
  291. },
  292. {
  293. "id": "ada-similarity",
  294. "object": "model",
  295. "created": 1651172507,
  296. "owned_by": "openai-dev"
  297. },
  298. {
  299. "id": "code-search-ada-code-001",
  300. "object": "model",
  301. "created": 1651172507,
  302. "owned_by": "openai-dev"
  303. },
  304. {
  305. "id": "text-similarity-ada-001",
  306. "object": "model",
  307. "created": 1651172505,
  308. "owned_by": "openai-dev"
  309. },
  310. {
  311. "id": "canary-whisper",
  312. "object": "model",
  313. "created": 1699656801,
  314. "owned_by": "system"
  315. },
  316. {
  317. "id": "whisper-1",
  318. "object": "model",
  319. "created": 1677532384,
  320. "owned_by": "openai-internal"
  321. },
  322. {
  323. "id": "text-search-curie-doc-001",
  324. "object": "model",
  325. "created": 1651172509,
  326. "owned_by": "openai-dev"
  327. },
  328. {
  329. "id": "text-curie-001",
  330. "object": "model",
  331. "created": 1649364043,
  332. "owned_by": "openai"
  333. },
  334. {
  335. "id": "curie",
  336. "object": "model",
  337. "created": 1649359874,
  338. "owned_by": "openai"
  339. },
  340. {
  341. "id": "canary-tts",
  342. "object": "model",
  343. "created": 1699492935,
  344. "owned_by": "system"
  345. },
  346. {
  347. "id": "tts-1",
  348. "object": "model",
  349. "created": 1681940951,
  350. "owned_by": "openai-internal"
  351. },
  352. {
  353. "id": "gpt-3.5-turbo-1106",
  354. "object": "model",
  355. "created": 1698959748,
  356. "owned_by": "system"
  357. },
  358. {
  359. "id": "gpt-3.5-turbo-0613",
  360. "object": "model",
  361. "created": 1686587434,
  362. "owned_by": "openai"
  363. },
  364. {
  365. "id": "gpt-3.5-turbo-0301",
  366. "object": "model",
  367. "created": 1677649963,
  368. "owned_by": "openai"
  369. },
  370. {
  371. "id": "gpt-3.5-turbo",
  372. "object": "model",
  373. "created": 1677610602,
  374. "owned_by": "openai"
  375. },
  376. {
  377. "id": "davinci",
  378. "object": "model",
  379. "created": 1649359874,
  380. "owned_by": "openai"
  381. },
  382. {
  383. "id": "dall-e-2",
  384. "object": "model",
  385. "created": 1698798177,
  386. "owned_by": "system"
  387. },
  388. {
  389. "id": "tts-1-1106",
  390. "object": "model",
  391. "created": 1699053241,
  392. "owned_by": "system"
  393. }
  394. ]
  395. }

其中里面的id  就是该apikey 可以调用的模型

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/513695
推荐阅读
相关标签
  

闽ICP备14008679号