Skip to content

Commit

Permalink
Merge pull request #346 from Portkey-AI/vrushankportkey-patch-1
Browse files Browse the repository at this point in the history
Node example fixes
  • Loading branch information
VisargD authored May 9, 2024
2 parents 9fe2de1 + 6994721 commit 30e462d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders

gateway = OpenAI(
api_key="ANTHROPIC_API_KEY",
base_url=PORTKEY_GATEWAY_URL, # Or http://localhost:8787/v1 if you are running locally
base_url=PORTKEY_GATEWAY_URL, # Or http://localhost:8787/v1 when running locally
default_headers=createHeaders(
provider="anthropic",
api_key="PORTKEY_API_KEY" # Grab from https://app.portkey.ai Not needed if you are running locally
api_key="PORTKEY_API_KEY" # Grab from https://app.portkey.ai # Not needed when running locally
)
)

Expand All @@ -106,19 +106,21 @@ import OpenAI from 'openai';
import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'

const gateway = new OpenAI({
apiKey: "ANTHROPIC_API_KEY",
baseURL: PORTKEY_GATEWAY_URL,
apiKey: "ANTHROPIC_API_KEY",
baseURL: PORTKEY_GATEWAY_URL, // Or http://localhost:8787/v1 when running locally
defaultHeaders: createHeaders({
provider: "anthropic",
apiKey: "PORTKEY_API_KEY"
apiKey: "PORTKEY_API_KEY" // Grab from https://app.portkey.ai / Not needed when running locally
})
});

async function main(){
const chatCompletion = await portkey.chat.completions.create({
const chatCompletion = await portkey.chat.completions.create({
messages: [{ role: 'user', content: 'Who are you?' }],
model: 'claude-3-sonnet-20240229',
});
maxTokens:512
});
console.log(chatCompletion.choices[0].message.content);
}

main()
Expand Down

0 comments on commit 30e462d

Please sign in to comment.