': {'message': 'The model `text-embedding-3-small` does not exist or you do not ...

2025年09月09日 20:43 响应: 1.96秒 状态: success

🚨 错误信息

现在使用 openai 库调用 embedding 模型 text-embedding-3-small 时,始终会抛异常 {'error': {'message': 'The model `text-embedding-3-small` does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}, 'request_id': 'bfd18b9f-265c-4e48-a912-1195895becbd'}

🤖 AI解决方案

{'error': {'message': '模型 `text-embedding-3-small` 不存在,或者您没有访问权限。', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}, 'request_id': 'bfd18b9f-265c-4e48-a912-1195895becbd'}

原因分析

您指定的 embedding 模型 text-embedding-3-small 不存在或您没有权限访问。

解决方案

请确认您使用的模型名称是否正确,并检查您的 OpenAI API 账户是否有权限使用该模型。如果需要使用 text-embedding-3-small,请确保模型名称拼写无误。

from openai import OpenAI

client = OpenAI(
    # 确保您的 API 密钥是正确的
    api_key="YOUR_API_KEY",
)

try:
    response = client.embeddings.create(
        input="Your text string goes here",
        model="text-embedding-3-small"  # 确认此模型名称是否有效
    )
    print(response)
except Exception as e:
    print(f"An error occurred: {e}")

预防措施

  • 在调用 OpenAI API 前,先通过 OpenAI 官方文档或 Playground 确认模型名称的有效性和可用性。
  • 在代码中使用 try-except 块来捕获潜在的 API 调用错误,并提供更友好的错误提示。