| parameter name | type | necessary | Instructions | example value |
|---|---|---|---|---|
| api_key | string | yes | Access API key for authentication purposes | sk - XyLy**************************mIqSt |
| base_url | string | yes | The basic address of the API service, specifying the access path for the model service | https://llm.ai-nebula.com |
| model | string | yes | Large language model identification for generating answers | claude - sonnet - 4 - 20250514 GPT-4o |
| messages | array | yew | Dialogue message list, including system role definitions and user questions Each element is an object, including: - role:role(user/system/assistant) - content:message content | { "role": "user", "content": "hello" } |
| temperature | number | No | Control the randomness of generated content, with higher 0-2 values indicating stronger response randomness | 0.7 |
Artificial intelligence is a new technical science that researches and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence. It attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a manner similar to human intelligence.| Exception Type | Trigger Scenario | Return Message |
|---|---|---|
| AuthenticationError | API key is invalid, expired, or unauthorized | Error: API key is invalid or unauthorized |
| NotFoundError | The specified model ID does not exist or is not supported by the server | Error: Model [model name] does not exist or is not supported |
| APIConnectionError | Network interruption, base_url error, or server unresponsive | Error: Unable to connect to the API server |
| APIError | Server-side exceptions such as API request format errors, insufficient permissions, etc. | API request failed: [error details] |
| Other Uncaught Exceptions | Code logic errors, unexpected data formats, etc. | Unknown error occurred: [error details] |
AI Response Content:
Artificial intelligence is a new technical science that researches and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence. Its core includes fields such as machine learning, natural language processing, and computer vision. It is widely applied in industries like healthcare, finance, and transportation, and is profoundly changing human production and lifestyles.AI Response Content:
Error: API key is invalid or unauthorizedapi_key, base_url, and model in the code are required values. If modifications are needed, please adjust the corresponding fields directly within the function.messages list contains conversation history; the system role is used to set model behavior, and the user role represents the current user question.temperature parameter between 0 and 2, where 0 indicates more deterministic generated content, and 2 indicates greater randomness.messages parameter by appending historical conversation records (including responses from the assistant role).openai Python library; please ensure it is installed before use (pip install openai).