AS AgentScopeAPI 手册 / API Reference
类class agentscope.credential

OpenAICredential

class OpenAICredential(CredentialBase)
源码Source agentscope/credential/_openai.py:17–90

OpenAI 凭证模型。位于 agentscope.credential 包,继承自 CredentialBase。核心成员包括 get_chat_model_class、get_chat_model_classes、get_embedding_model_class、get_tts_model_classes、get_asr_model_classes、get_realtime_model_classes。

The OpenAI credential model. Declared in agentscope.credential. Extends CredentialBase.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
model_config—
模型配置字段。
ConfigDict(title='OpenAI API')
typeLiteral['openai_credential']
类型字段。
'openai_credential'
api_keySecretStr
OpenAI API 密钥。
Field(description='The OpenAI API key.')
organizationstr | None
`organization` 字段。
Field(default=None, description='The OpenAI organization ID.')
base_urlstr | None
基类 URL字段。
Field(default=None, description='The base URL for the OpenAI API. Can be used for OpenAI-compatible endpoints.')

方法摘要Method Summary

方法Method说明Description
def get_chat_model_class() -> Type['ChatModelBase']
返回OpenAIChatModel 类。
Return the OpenAIChatModel class.
def get_chat_model_classes() -> list[Type['ChatModelBase']]
获取 `get_chat_model_classes`。
Return both APIs unless the legacy getter selects a custom model.
def get_embedding_model_class() -> Type['EmbeddingModelBase']
返回OpenAIEmbeddingModel 类。
Return the OpenAIEmbeddingModel class.
def get_tts_model_classes() -> list[Type['TTSModelBase']]
获取 `get_tts_model_classes`。
Return the OpenAI TTS model classes.
def get_asr_model_classes() -> list[Type['ASRModelBase']]
获取 `get_asr_model_classes`。
Return the OpenAI transcription implementation.
def get_realtime_model_classes() -> list[Type['RealtimeModelBase']]
获取 `get_realtime_model_classes`。
Return the OpenAI realtime model classes.

属性详情Attribute Detail

model_config

 = ConfigDict(title='OpenAI API')

模型配置字段。

OpenAI API

源码Source agentscope/credential/_openai.py:20

type

Literal['openai_credential'] = 'openai_credential'

类型字段。声明为 Literal['openai_credential']。

The type field.

源码Source agentscope/credential/_openai.py:24

api_key

SecretStr = Field(description='The OpenAI API key.')

OpenAI API 密钥。

The OpenAI API key.

源码Source agentscope/credential/_openai.py:27

organization

str | None = Field(default=None, description='The OpenAI organization ID.')

organization 字段。声明为 str | None。

The OpenAI organization ID.

源码Source agentscope/credential/_openai.py:32

base_url

str | None = Field(default=None, description='The base URL for the OpenAI API. Can be used for OpenAI-compatible endpoints.')

基类 URL字段。声明为 str | None。

The base URL for the OpenAI API.

源码Source agentscope/credential/_openai.py:38

方法详情Method Detail

get_chat_model_class

def get_chat_model_class() -> Type['ChatModelBase']

返回OpenAIChatModel 类。

Return the OpenAIChatModel class.

返回Returns Type['ChatModelBase']
返回类型['ChatModelBase']。Returns type chat model base.
源码Source agentscope/credential/_openai.py:48–52

get_chat_model_classes

def get_chat_model_classes() -> list[Type['ChatModelBase']]

获取 get_chat_model_classes。

Return both APIs unless the legacy getter selects a custom model.

返回Returns list[Type['ChatModelBase']]
返回类型['ChatModelBase']列表。Returns a list of type chat model base.
源码Source agentscope/credential/_openai.py:55–62

get_embedding_model_class

def get_embedding_model_class() -> Type['EmbeddingModelBase']

返回OpenAIEmbeddingModel 类。

Return the OpenAIEmbeddingModel class.

返回Returns Type['EmbeddingModelBase']
返回类型['EmbeddingModelBase']。Returns type embedding model base.
源码Source agentscope/credential/_openai.py:65–69

get_tts_model_classes

def get_tts_model_classes() -> list[Type['TTSModelBase']]

获取 get_tts_model_classes。

Return the OpenAI TTS model classes.

返回Returns list[Type['TTSModelBase']]
返回类型['TTSModelBase']列表。Returns a list of type TTS model base.
源码Source agentscope/credential/_openai.py:72–76

get_asr_model_classes

def get_asr_model_classes() -> list[Type['ASRModelBase']]

获取 get_asr_model_classes。

Return the OpenAI transcription implementation.

返回Returns list[Type['ASRModelBase']]
返回类型['ASRModelBase']列表。Returns a list of type ASR model base.
源码Source agentscope/credential/_openai.py:79–83

get_realtime_model_classes

def get_realtime_model_classes() -> list[Type['RealtimeModelBase']]

获取 get_realtime_model_classes。

Return the OpenAI realtime model classes.

返回Returns list[Type['RealtimeModelBase']]
返回类型['RealtimeModelBase']列表。Returns a list of type realtime model base.
源码Source agentscope/credential/_openai.py:86–90

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.