PageSourceSearch

https://short-gpt-dcs.vercel.app/assets/js/d9490ae8.948a71d4.js

js short-gpt-dcs.vercel.app collected 2026-10-03 07:42:02 UTC 6,505 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkshortgpt_documentation=self.webpackChunkshortgpt_documentation||[]).push([[128],{3905:(e,t,a)=>{a.d(t,{Zo:()=>y,kt:()=>u});var n=a(7294);function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function o(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?i(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):i(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function p(e,t){if(null==e)return{};var a,n,r=function(e,t){if(null==e)return{};var a,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var s=n.createContext({}),l=function(e){var t=n.useContext(s),a=t;return e&&(a="function"==typeof e?e(t):o(o({},t),e)),a},y=function(e){var t=l(e.components);return n.createElement(s.Provider,{value:t},e.children)},d="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},g=n.forwardRef((function(e,t){var a=e.components,r=e.mdxType,i=e.originalType,s=e.parentName,y=p(e,["components","mdxType","originalType","parentName"]),d=l(a),g=r,u=d["".concat(s,".").concat(g)]||d[g]||c[g]||i;return a?n.createElement(u,o(o({ref:t},y),{},{components:a})):n.createElement(u,o({ref:t},y))}));function u(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=a.length,o=new Array(i);o[0]=g;var p={};for(var s in t)hasOwnProperty.call(t,s)&&(p[s]=t[s]);p.originalType=e,p[d]="string"==typeof e?e:r,o[1]=p;for(var l=2;l<i;l++)o[l]=a[l];return n.createElement.apply(null,o)}return n.createElement.apply(null,a)}g.displayName="MDXCreateElement"},2927:(e,t,a)=>{a.r(t),a.d(t,{assets:()=>s,contentTitle:()=>o,default:()=>c,frontMatter:()=>i,metadata:()=>p,toc:()=>l});var n=a(7462),r=(a(7294),a(3905));const i={title:"ApiKeyManager in ShortGPT",sidebar_label:"ApiKeyManager"},o="ApiKeyManager in ShortGPT",p={unversionedId:"api-key-manager",id:"api-key-manager",title:"ApiKeyManager in ShortGPT",description:"ApiKeyManager is a class in the ShortGPT framework that manages the API keys for different providers. It interacts with the database to get and set API keys.",source:"@site/docs/api-key-manager.mdx",sourceDirName:".",slug:"/api-key-manager",permalink:"/docs/api-key-manager",draft:!1,editUrl:"https://github.com/RayVentura/ShortGPT/edit/stable/docs/docs/api-key-manager.mdx",tags:[],version:"current",lastUpdatedBy:"RayV",lastUpdatedAt:1736759328,formattedLastUpdatedAt:"Jan 13, 2025",frontMatter:{title:"ApiKeyManager in ShortGPT",sidebar_label:"ApiKeyManager"},sidebar:"docs",previous:{title:"FactsShortEngine",permalink:"/docs/facts-short-engine"},next:{title:"AssetDatabase",permalink:"/docs/asset-database"}},s={},l=[{value:"Importing ApiKeyManager",id:"importing-apikeymanager",level:2},{value:"Using ApiKeyManager",id:"using-apikeymanager",level:2},{value:"set_api_key",id:"set_api_key",level:3},{value:"get_api_key",id:"get_api_key",level:3},{value:"Note",id:"note",level:2}],y={toc:l},d="wrapper";function c(e){let{components:t,...a}=e;return(0,r.kt)(d,(0,n.Z)({},y,a,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"apikeymanager-in-shortgpt"},"ApiKeyManager in ShortGPT"),(0,r.kt)("p",null,"ApiKeyManager is a class in the ShortGPT framework that manages the API keys for different providers. It interacts with the database to get and set API keys."),(0,r.kt)("h2",{id:"importing-apikeymanager"},"Importing ApiKeyManager"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-python"},"from shortGPT.config.api_db import ApiKeyManager, ApiProvider\n")),(0,r.kt)("h2",{id:"using-apikeymanager"},"Using ApiKeyManager"),(0,r.kt)("p",null,"ApiKeyManager provides two main methods: ",(0,r.kt)("inlineCode",{parentName:"p"},"get_api_key")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"set_api_key"),"."),(0,r.kt)("h3",{id:"set_api_key"},"set_api_key"),(0,r.kt)("p",null,"This method is used to set the API key for a specific provider in the database. It takes two arguments: the key (provider name) and the value (API key)."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-python"},'ApiKeyManager.set_api_key(ApiProvider.OPENAI, "your_openai_key")\nApiKeyManager.set_api_key(ApiProvider.ELEVEN_LABS, "your_eleven_labs_key")\n')),(0,r.kt)("p",null,"In the above example, we are setting the API keys for OPENAI and ELEVEN_LABS."),(0,r.kt)("h3",{id:"get_api_key"},"get_api_key"),(0,r.kt)("p",null,"This method is used to retrieve the API key for a specific provider from the database. It takes one argument: the key (provider name)."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-python"},"openai_key = ApiKeyManager.get_api_key(ApiProvider.OPENAI)\neleven_labs_key = ApiKeyManager.get_api_key(ApiProvider.ELEVEN_LABS)\n")),(0,r.kt)("p",null,"In the above example, we are retrieving the API keys for OPENAI and ELEVEN_LABS."),(0,r.kt)("h2",{id:"note"},"Note"),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"key")," argument in both methods can either be a string or an instance of the ",(0,r.kt)("inlineCode",{parentName:"p"},"ApiProvider")," enum. If it is an instance of ",(0,r.kt)("inlineCode",{parentName:"p"},"ApiProvider"),", the ",(0,r.kt)("inlineCode",{parentName:"p"},"value")," attribute of the enum instance will be used as the key."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-python"},'ApiKeyManager.set_api_key("OPENAI_API_KEY", "your_openai_key")\nApiKeyManager.set_api_key("ELEVENLABS_API_KEY", "your_eleven_labs_key")\n\nopenai_key = ApiKeyManager.get_api_key("OPENAI_API_KEY")\neleven_labs_key = ApiKeyManager.get_api_key("ELEVENLABS_API_KEY")\n')),(0,r.kt)("p",null,"In the above example, we are setting and retrieving the API keys using string keys instead of ",(0,r.kt)("inlineCode",{parentName:"p"},"ApiProvider")," instances."))}c.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.