Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I send a prompt using the Python OpenAI client? #6

Open
NightMachinery opened this issue Mar 23, 2024 · 0 comments
Open

How do I send a prompt using the Python OpenAI client? #6

NightMachinery opened this issue Mar 23, 2024 · 0 comments

Comments

@NightMachinery
Copy link

NightMachinery commented Mar 23, 2024

The site has this example code for sending ChatML messages:

from openai import OpenAI
from os import getenv

# gets API Key from environment variable OPENAI_API_KEY
client = OpenAI(
  base_url="https://openrouter.ai/api/v1",
  api_key=getenv("OPENROUTER_API_KEY"),
)

completion = client.chat.completions.create(
  model="anthropic/claude-3-opus:beta",
  messages=[
    {
      "role": "user",
      "content": "Say this is a test",
    },
  ],
)
print(completion.choices[0].message.content)

But I can't find how I can send a simple prompt (with no instruct formatting) in Python and get the response streamed.

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant