Showing posts with label api. Show all posts
Showing posts with label api. Show all posts

Using AI with .NET 10 Scripts: What Worked, What Didn’t, and Lessons Learned

I wanted to kick the tires on the upcoming .NET 10 C# script experience and see how far I could get calling Reka’s Research LLM from a single file, no project scaffolding, no .csproj. This isn’t a benchmark; it’s a practical tour to compare ergonomics, setup, and the little gotchas you hit along the way. I’ll share what worked, what didn’t, and a few notes you might find useful if you try the same.

All the sample code (and a bit more) is here: reka-ai/api-examples-dotnet · csharp10-script. The scripts run a small “top 3 restaurants” prompt so you can validate everything quickly.

We’ll make the same request in three ways:

  1. OpenAI SDK
  2. Microsoft.Extensions.AI for OpenAI
  3. Raw HttpClient

What you need

The C# "script" feature used below ships with the upcoming .NET 10 and is currently available in preview. If you prefer not to install a preview SDK, you can run everything inside the provided Dev Container or on GitHub Codespaces. I include a .devcontainer folder with everything set up in the repo.

Set up your API key

We are talking about APIs here, so of course, you need an API key. The good news is that it's free to sign up with Reka and get one! It's a 2-click process, more details in the repo. The API key is then stored in a .env file, and each script loads environment variables using DotNetEnv.Env.Load(), so your key is picked up automatically. I went this way instead of using dotnet user-secrets because I thought it would be the way it would be done in a CI/CD pipeline or a quick script.

Run the demos

From the csharp10-script folder, run any of these scripts. Each line is an alternative

dotnet run 1-try-reka-openai.cs
dotnet run 2-try-reka-ms-ext.cs
dotnet run 3-try-reka-http.cs

You should see a short list of restaurant suggestions.

Propmt Result: 3 restaurants


OpenAI SDK with a custom endpoint

Reka's API is using the OpenAI format; therefore, I thought of using the NuGet package OpenAI. To reference a package in a script, you use the #:package [package name]@[package version] directive at the top of the file. Here is an example:

#:package OpenAI@2.3.0

// ...

var baseUrl = "http://api.reka.ai/v1";

var openAiClient = new OpenAIClient(new ApiKeyCredential(REKA_API_KEY), new OpenAIClientOptions
{
    Endpoint = new Uri(baseUrl)
});

var client = openAiClient.GetChatClient("reka-flash-research");

string prompt = "Give me 3 nice, not crazy expensive, restaurants for a romantic dinner in Montreal";

var completion = await client.CompleteChatAsync(
    new List<ChatMessage>
    {
        new UserChatMessage(prompt)
    }
);

var generatedText = completion.Value.Content[0].Text;

Console.WriteLine($" Result: \n{generatedText}");

The rest of the code is more straightforward. You create a chat client, specify the Reka API URL, select the model, and then you send a prompt. And it works just as expected. However, not everything was perfect, but before I share more about that part, let's talk about Microsoft.Extensions.AI.

Microsoft Extensions AI for OpenAI

Another common way to use LLM in .NET is to use one ot the Microsoft.Extensions.AI NuGet package. In our case Microsoft.Extensions.AI.OpenAI was used.

#:package Microsoft.Extensions.AI.OpenAI@9.8.0-preview.1.25412.6

// ....

var baseUrl = "http://api.reka.ai/v1";

IChatClient client = new ChatClient("reka-flash-research", new ApiKeyCredential(REKA_API_KEY), new OpenAIClientOptions
{
    Endpoint = new Uri(baseUrl)
}).AsIChatClient();

string prompt = "Give me 3 nice, not crazy expensive, restaurants for a romantic dinner in Montreal";

Console.WriteLine(await client.GetResponseAsync(prompt));

As you can see, the code is very similar. Create a chat client, set the URL, the model, and add your prompt, and it works just as well.

That's two ways to use Reka API with different SDKs, but maybe you would prefer to go "SDKless", let's see how to do that.

Raw HttpClient calling the REST API

Without any SDK to help, there is a bit more line of code to write, but it's still pretty straightforward. Let's see the code:

using var httpClient = new HttpClient();

var baseUrl = "http://api.reka.ai/v1/chat/completions";

var requestPayload = new
{
    model = "reka-flash-research",
    messages = new[]
            {
                new
                {
                    role = "user",
                    content = "Give me 3 nice, not crazy expensive, restaurants for a romantic dinner in New York city"
                }
            }
};

using var request = new HttpRequestMessage(HttpMethod.Post, baseUrl);
request.Headers.Add("Authorization", $"Bearer {REKA_API_KEY}");
request.Content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");

var response = await httpClient.SendAsync(request);

var responseContent = await response.Content.ReadAsStringAsync();

var jsonDocument = JsonDocument.Parse(responseContent);

var contentString = jsonDocument.RootElement
    .GetProperty("choices")[0]
    .GetProperty("message")
    .GetProperty("content")
    .GetString();

Console.WriteLine(contentString);

So you create an HttpClient, prepare a request with the right headers and payload, send it, get the response, and parse the JSON to extract the text. In this case, you have to know the JSON structure of the response, but it follows the OpenAI format.

What did I learn from this experiment?

I used VS Code while trying the script functionality. One thing that surprised me was that I didn't get any IntelliSense or autocompletion. I try to disable the DevKit extension and change the setting for OmniSharp, but no luck. My guess is that because it's in preview, and it will work just fine in November 2025 when .NET 10 will be released.

In this light environment, I encountered some issues where, for some reason, I couldn't use an https endpoint, so I had to use http. In the raw httpClient script, I had some errors with the Reflection that wasn't available. It could be related to the preview or something else, I didn't investigate further.

For the most part, everything worked as expected. You can use C# code to quickly execute some tasks without any project scaffolding. It's a great way to try out the Reka API and see how it works.

What's Next?

While writing those scripts, I encountered multiple issues that aren't related to .NET but more about the SDKs when trying to do more advanced functionalities like optimization of the query and formatting the response output. Since it goes beyond the scope of this post, I will share my findings in a follow-up post. Stay tuned!

Video version

Here is a video version of this post


Learn more

Get an AI assistant to do your research

Introducing Reka Research: Your AI Research Assistant

An AI Assistant searching in documents
Meet Reka Research a powerful AI agent that can search the web and analyze your files to answer complex questions in minutes. Whether you're staying up to date with AI news, screening resumes, or researching technical topics, Reka Research does the heavy lifting for you.


What Makes Reka Research Special?

Reka Research stands out in four key areas:

  • Top Performance: Best in class results on research benchmarks
  • Fast Results: Get thorough answers in 1-3 minutes
  • Full Transparency: See exactly how the AI reached its conclusions. All steps are visible.

Smart Web Search That Actually Works

Ever wished you could ask someone to research the latest AI developments while you focus on other work? That's exactly what Reka Research does.

Watch how it works:

In this demo, Jess and Sharath shows how Reka Research can automatically gather the most important AI news from the past week. The AI visits multiple websites, takes notes, and presents a clean summary with sources. You can even restrict searches to specific domains or set limits on how many sites to check.

File Search for Your Private Documents

Sometimes the information you need isn't on the web - it's in your company's documents, meeting notes, or file archives. Reka Research can search through thousands of private files to find exactly what you're looking for.

See it in action:  

In this example, ess and Sharath shows how HR teams can use Reka Research to quickly screen resumes. Instead of manually reviewing hundreds of applications, the AI finds candidates who meet specific requirements (like having a computer science degree and 3+ years of backend experience) in seconds!

Writing Better Prompts Gets Better Results

Like any AI tool, Reka Research works best when you know how to ask the right questions. The key is being specific about what you want and providing context.

Learn the techniques:

Jess and Yi shares practical tips for getting the most out of Reka Research. Instead of asking "summarize meeting minutes," try "summarize April meeting minutes about public participation." The more specific you are, the better your results will be.

Ready to Try Reka Research?

Reka Research is currently available for everyone! Try it via the playground, or using directly the API. Whether you're researching competitors, analyzing documents, or staying current with industry trends, it can save you hours of work.

Want to learn more and connect with other users? Join our Discord community where you can:

  • Get tips from other Reka Research users
  • Share your use cases and success stories
  • Stay updated on new features and releases
  • Ask questions directly to our team

Join our Discord Community

Ready to transform how you research? Visit reka.ai to learn more about Reka Research and our other AI tools.

Reading Notes #649

Welcome to another edition of my reading notes! This week I've come across some interesting articles spanning from programming decisions to career tips and AI innovations. Hope you find something valuable in this collection.
minimal photography of a point of land in sandwich between gray sky and water

Programming


AI


Miscellaneous

  • Thriving After a Layoff: The First 30 Days (scrappy girl project) - A friend of mine shared with me this post, and I think it will help me in the upcoming days. So here I am sharing so more can benefit from it

Book cover: The Let Them Theory

Books

  • The Let Them Theory (Mel Robbins) - Stop wasting energy on things you can’t control. It something we all know, but probably forgot the power if it. Let go is hard, but it works in so many scenario. In this book Mel explains how to make it works, and how to use it with a let me action.
     

Sharing my Reading Notes is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week. 

If you have interesting content, share it!

~Frank


Reading Notes #646

Welcome to this week's collection of fascinating reads across cloud computing, AI, and programming! As technology continues to evolve at breakneck speed, I've gathered some of the most insightful articles that caught my attention. From securing MCP servers to exploring Rust, there's something here for every tech enthusiast. 
Dive in and discover what's new in our rapidly changing digital landscape.

Cloud

AI

Programming

Sharing my Reading Notes is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week. 

If you have interesting content, share it!

~Frank

Reading Notes #638

Welcome to Reading Notes —a curated dive into the latest and greatest in programming, cloud, and AI. From mastering multithreading with Azure to exploring GitHub Copilot's productivity potential, this collection is brimming with knowledge. Let's unravel what's new, innovative, and worth your attention!


Cloud


Programming

AI

Sharing my Reading Notes is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week. 

If you have interesting content, share it! 

~frank


Reading Notes #637

In this edition of my Reading Notes, I've curated some fascinating content that spans across programming, creativity, and enlightening podcasts. Whether you're eager to enhance your coding skills, explore unique ideas, or stay updated with the latest in the tech world, there's something here for everyone. 
Dive in and enjoy these insightful reads and discussions!

Programming

Podcasts

Miscellaneous



Sharing my Reading Notes is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week. If you have interesting content, share it! 

 ~Frank

Reading Notes #628

A phone connected to a screen, keyboard, and mouse

For this week reading notes, I have some exciting blog posts and podcast episodes. Covering topics including .NET scaffolding, Visual Studio updates, the Builder Pattern in C#, and OpenAPI in .NET 9. Plus, tips on validating identity with GitHub, improving Azure Identity, and podcast highlights on GitHub Universe and presentation skills. 

Cloud


Programming


Podcasts


Miscellaneous


Sharing my Reading Notes is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you have interesting content, share it!


~Frank


Reading Notes #619

It's reading notes time! It is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week. 

You also read something you liked? Share it!

Suggestion of the week

Programming

~Frank

Reading Notes #601

It's reading notes time! It is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week.

Having interesting content? Share it! 


Suggestion of the week

  • Announcing: Azure Developers (Mehul Harry) - Looking forward to this event. I have the pleasure to present a session with Jerry Nixon about Data API Builder. Join us!

Cloud

  • Demystifying Azure CLI pagnination (Jeremy Li) - That's great! It's so sad when all the information is "throw" on us without any control and it's on us to find our "needle" we are looking for in those screens full of line. This will definitely helps.

Programming

Open Source

~ Frank

Reading Notes #593

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you think you may have interesting content, share it!

Cloud

Programming

Miscellaneous

~Frank

Reading Notes #591

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you think you may have interesting content, share it!

Suggestion of the week

Cloud

Programming

~ Frank

Reading Notes #590

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you think you may have interesting content, share it!

Cloud

Programming

Miscellaneous

  • Introducing Sudo for Windows! (Jordi Adoumie) - Wow! This is a really good new feature. How many time a forgot to start my terminal as admin and needed to starry over again...Looking forward to try it.
~Frank


Reading Notes #589

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you think you may have interesting content, share it!

Cloud

Programming

  • Understanding C# 8 default interface methods (Andrew Lock) - Very clear post about the new feature available in interfaces, with great examples that make us understand why and when it is useful and how to implement it.

Open Source

Podcasts

~Frank

Reading Notes #588

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you think you may have interesting content, share it!

Programming

~Frank

Reading Notes #576

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.


If you think you may have interesting content, share it!


Suggestion of the week

  • Visual Studio Code: C# Dev Kit Now Generally Available (Almir Vuk) - As a .NET developer that spend a lot of time in Linux, I was already using a lot VSCode and started using DevKit curious to see if if would really helps. I felt empowered. Great work, and congrats on the GA that was fast!

Programming


Podcasts

  • What do we want from a web browser? (The Changelog: Software Development, Open Source) - I think it was my first episode of The Changelog. I liked it. Interesting discussion about what should be a "good" web browser...

~Frank

Reading Notes #575

Happy Thanksgiving to all Canadian🍁! 

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you think you may have interesting content, share it!

Suggestion of the week

Programming

Open Source

Podcasts

~Frank

Reading Notes #571

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week. 

If you think you may have interesting content, share it!

Cloud

Programming

Open Source

Miscellaneous


~Frank


Reading Notes #567

Programming

DevOps

  • How to deploy Azure Container Apps (Shawn Sesna) - This is a grewt tutorial to get your container Apps deploy without having to care about to much infrastructure aka.kubernetes.

Podcasts

Frank

Reading Notes #565


It's time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week.

If you think you may have interesting content, share it!


Cloud

Programming

Data

Low Code

Podcast

Miscellaneous

~Frank


Reading Notes #564


Monday! It is time to share my reading notes. It is a habit I started a long time ago where I share a list of all blog posts that catch my interest during the week. 

If you think you may have interesting content, share it!

 

Cloud

DevOps

Programming

Data

~Frank