Skip to content

[Feature Request]: Support for Openai-Like Completion API #4705

Closed
@StanleySun233

Description

@StanleySun233

Is there an existing issue for the same feature request?

  • I have checked the existing issues.

Is your feature request related to a problem?

Describe the feature you'd like

After designing the agent, I want to use the model in third-party interface open-webui as it provide some feature like arena.

Question #3760 mentioned the feature OpenAI compatible server API, which means the server should support api like: /api/v1/{agents,chats}/chat/{models,completions}

When checking the roadmap for 2024 & 2025, this feature has not been added. I hope this feature requirement can be supported.

Describe implementation you've considered

/api/v1/agents/chat/completions

/api/v1/agents/chat/models

/api/v1/chats/chat/completions

/api/v1/chats/chat/models

Documentation, adoption, use case

# use like openai-api
from openai import OpenAI

address = "addr" 
chat_id = "chatid"

client = OpenAI(
    api_key="ak",
    base_url=f"http://{address}/api/v1/agents"
)

completion = client.chat.completions.create(
    model=chat_id,
    messages=[
        # auto-fill with the default "Begin"'s "Opener"
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'Who you are?'}
        ]
)
print(completion)
print(completion.choices[0].message.content)

Additional information

sample from tongyi

from openai import OpenAI

client = OpenAI(
    api_key="sk",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen-plus",
    messages=[
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'who you are?'}
        ]
)
print(completion.choices[0].message.content)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions